I'm trying to create a bunch of Facter facts in a loop.  The code
inside is evaluated at some weird time, *out of order*, and I don't
know enough Ruby to fix it.  The goal is to get access to user
homedirs, because I can't figure out any other way to do that in
Puppet.

Here's a few tries:

      passwd = IO.readlines('/etc/passwd')
      passwd.each do |line|
          line =~ /(.*):(.*):(.*):(.*):(.*):(.*):(.*)/
          Facter.add("home_#{$1}") do
              setcode do
                  #{$6}
              end
          end
      end

This ends up with every home_$user fact having the same homedir
listed as the liste user in /etc/passwd.

    passwd = IO.readlines('/etc/passwd')

    homes = Array.new
    index = 0

    passwd.each do |line|
        line =~ /(.*):(.*):(.*):(.*):(.*):(.*):(.*)/
        homes.push $6
        Facter.add("home_#{$1}") do
            setcode do
                    puts "stuff: "+", "+index.to_s+", "+homes[index]
                index += 1
                homes[index-1]
            end
        end
    end

This ends up with home_$user fact having a randomly selected, but
distinct homedir.

Help?

-Robin

-- 
They say:  "The first AIs will be built by the military as weapons."
And I'm thinking:  "Does it even occur to you to try for something
other than the default outcome?" -- http://shorl.com/tydruhedufogre
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to