Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to deploy a simple text file (a git commit message template) to each user's home directory using Puppet.

I came across this post which seems very close, but the part I'm not clear on is how do I generate a list of users for each node?

In the post they hardcode the users like this:

 applink::desktoplinks { [ "user1", "user2", "user3" ]: }

I can't hard-code the list because these are developer machines and might have a variety of different users that are specific to each node.

Looking at this post, I think I need to use virtual resources, but being a total newbie, just by reading the docs and the provided samples I can't quite seem to figure it out.

Can somebody point me to a quick sample or recipe somewhere that illustrates how to do this?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

To generate a list of users you need to create a new fact. Any information that comes from the host that will be configured needs to be a fact.

For example, the following fact returns the whole /etc/passwd:

# etcpasswd.rb

Facter.add("etcpasswd") do
        setcode do
                File.read('/etc/passwd')
        end
end

You put this fact on the lib/facter subdirectory of a module, or under plugins/facter in Puppet's base directory. I think you need pluginsync = true in puppet.conf too, but that might be only for older Puppet versions.

You can see an example of this at work on my puppet users module.

share|improve this answer

I am realtively new to puppet, so I am not sure if this is possible, but I suspect not.

Have you considered simply transmitting a copying your template, and a script to a single location on each box. Then setup an exec resource so that whenever the git template is updated, it will run the script. The script would loop over /home copying the files into the appropriate locations.

share|improve this answer
    
This is definitely the easiest way to go, but I was hoping to keep as much of the process with puppet's declarative style, mainly for consistency. –  Millhouse Oct 21 '11 at 16:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.