> I have a facter question, is the use of ruby environmental variables
> encouraged or discouraged? I noticed that path.rb uses the ruby ENV
> object, but id.rb does not use it. However, if id.rb did use it then
> it could be reduced to 5 lines like so:
>
> Facter.add(:id) do
> setcode do
> ENV['USER']
> end
> end
Not really answering your question, but when I just want to have
environment variables appear as facts, I use the (little known) ability
of facter to transform every variable prepended with "FACTER_" to a
fact:
$ FACTER_foo="bar" facter foo
bar
$ FACTER_now=$(date) facter now
Sun May 30 14:07:19 CEST 2010
Cheers,
Marc
Facter.envfact(:deploydate) { confine :kernel => %w{Windows} }
In general, the reason I've always avoided relying on ENV is that it's so easy for the data to not be right at different times, at least I think I've experienced that. It's always tough to track whether a given ENV variable is overwriteable, guaranteed, always set, etc.
Yea I noticed that the documentation is very hard to find concerning the ENV object and whether any ENV variables are guaranteed.Facter.envfact(:deploydate) { confine :kernel => %w{Windows} }Thanks that looks great.In general, the reason I've always avoided relying on ENV is that it's so easy for the data to not be right at different times, at least I think I've experienced that. It's always tough to track whether a given ENV variable is overwriteable, guaranteed, always set, etc.
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppe...@googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.