On Sat, Jan 03, 2009 at 05:13:01PM -0800, Robin Lee Powell wrote:
> What I end up with is:
>
> passwd = IO.readlines('/etc/passwd')
> passwd.each do |line|
> line =~ /(.*):(.*):(.*):(.*):(.*):(.*):(.*)/
> Facter.add("home_#{$1.dup}") do
The dup isn't actually needed here as the dereference happens instantly with
interpolation (to_s is called and a new String instance is returned).
> setcode do
> $6.dup
Here I wasn't sure but apparently it's irrelevant here, too. Sorry, don't know
enough about Facter in order to be able to help you further.
Btw, rather than parsing /etc/passwd yourself, why not let the Etc module do
the work for you?
Etc.passwd do |pwent|
Facter.add("home_#{pwent.name}") do
setcode do
pwent.dir
end
end
end
> end
> end
> end
>
> which does exactly the same thing:
>
> home_backup => /var/run/dbus
> home_bin => /var/run/dbus
[snip]
> /var/run/dbus is the home of the last /etc/passwd entry.
--
Jos Backus
jos at catnook.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---