Changing owner dynamically

I'm pretty new to puppet and have the below configuration setup on my master node, I know it's not the standard "module structure" but this fits my needs better. I want to apply the shlib.pp manifest to all nodes but under different owners per node. Is there anyway I can set the owner attribute as a variable in shlib.pp and then set it per node in site.pp rather than having to put the whole code into site.pp for each node ? Many thanks.

2 Answers

I would recommend using a module instead of an 'import' command. That allows you to pass parameters in directly. See https://docs.puppet.com/guides/moduleguides/bgtm.html for a beginner's guide to modules. if you, for instance, created a 'shlib' module, you would then be able to call it like this..

Comments

We don't have our svn repository setup in a module structure and that's what I'm using to serve the code to the agents. I don't want to have to either a) change the svn or b) write a script to checkout and move to a module format. Otherwise it will be just module folders with only manifest files?

module folders with only manifest files are also ok. I don't know how you are getting your puppet code to your nodes/master, but we currently rsync an entire hieradata,manifests,modules set of directories into our specific /etc/puppet/environment/<myenv>/

I have a svn checkout scheduled to the master (changed fileserver location) which is then used to serve the code to agents when updated. Given that it makes it easier for us to have one central location of manifest files rather than many empty "module" structures holding them.

Well not knowing what criteria youre using to determine the owner its tough to say, but essentially yes. If you were using a simple convention like my example above you could use a regex as a catch all so that server** always had the owner set as user** and the last two digits would match.