Reputation: 392
I've forked one of the existing package providers (appdmg.rb) to use in my module. I simply want to ask an extra parameter "path" as a custom installation target path. I use @resource[:path] in the modified module and I've put it in /lib subdirectory. After restarting puppet master, it is recognised and synchronised to agent properly - I've checked it's availability in /var/lib/puppet/ on the agent, but I get a parameter error during test run:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter path at /etc/puppet/modules/xcode/manifests/init.pp:6 on node lon02-mac-09.local
The manifest code is:
package {
"xcode-${version}" :
provider => 'appdmg2',
source => "/storage/xcode-${version}.dmg",
path => "/Applications/Xcode${version}.app",
}
Is there anything special I have to do to make it working?
Upvotes: 2
Views: 1629
Reputation: 4019
I was able to add a new parameter thus:
Puppet::Type.type(:package).newparam(:path) do
desc "Specify alternative package-path"
end
The above snippet lives in modules/YOURMODULE/lib/puppet/provider/package/YOURPROVIDER.rb
-- in the same file, where the actual provider-implementation itself resides.
Unfortunately, I still can't figure out, how to actually access the value of this parameter specified in the Puppet-manifest from inside my new package-provider...
Upvotes: 2
Reputation: 8223
It's not quite that simple. The provider
serves as the backend for a type
. To enable Puppet to use an additional parameter to the package
type, you will have to add it to the respective type code such as the source
param in the upstream code.
Once you patch that in, @resource[:path]
should indeed work inside the provider instances.
Of course, such additions are not suitable for a module, so you would techically need to actually add a new type of your own (and sadly, there is no subtyping yet).
It may be worth checking wether install_options can perhaps solve your problem using the existing provider.
Upvotes: 3