I'm currently using a module named "common" which is based off of David
Schmitt's work.
I'm having issues with it in OpenBSD, and the reason is that the
directory created to contain module-specific files is hardcoded to
/var/lib/pupppet/modules.
Now, I could easily special-case the path for OpenBSD and the other OSes
that don't keep their $vardir under this directory, but I was wondering
if it was possible to access variables from puppet.conf into the manifests.
If it could be possible, it would be more elegant to use the $vardir
value directly.
I've done a quick test to print (notify{}) the value of $vardir and it's
empty. Do you guys know of a way I could access this value within the
module's manifests?
--
Gabriel Filion
Yeah, that would make manifests a lot more flexible. Here's a function
that should work for this purpose and potentially other puppet
configuration variables as well:
# puppet_vardir.rb
module Puppet::Parser::Functions
newfunction(:puppet_vardir, :type => :rvalue) do
Puppet[:vardir]
end
end
# vardir.pp
notice (puppet_vardir())
# puppet apply vardir.pp
notice: Scope(Class[main]): /var/lib/puppet
# puppet apply vardir.pp --vardir=/tmp/
notice: Scope(Class[main]): /tmp
Thanks,
Nan
Since 2.6.0 you can just do notice($settings::vardir)
hmm, that's interestingly very simple. I would personally use a fact
instead of a function, but now that I know the ruby part to fetch the
config value, writing a fact shouldn't be too difficult.
thanks,
--
Gabriel Filion
oh .. I've just tried it out and it works. hurray for 2.6, then! :)
and, I'll also keep Nan Liu's suggestion in mind for 0.25.x
Thanks to everyone for the feedback!
--
Gabriel Filion