Ask Your Question

2 users 1 template

asked 2015-03-31 16:43:08 -0600

Rob D. gravatar image

I have a module which defines a few users, each of whom have slightly different needs (e.g., home directory, uid, gid, groups, etc.). I'll use netatalk as an example, since we're using it for server-based Time Machine backups.

Netatalk requires a file called /etc/netatalk/AppleVolumes.default, which should have an entry for each of the defined users, like so:

# AppleVolumes.default - Managed by Puppet - DO NOT EDIT BY HAND
:DEFAULT: options:upriv,usedots
/home/john/timemachine "John's TM on foo" options:tm allow:john allowed_hosts:
/home/jane/timemachine "Jane's TM on foo" options:tm allow:jane allowed_hosts:

Now, with one user, I can use template() to create John's entry in the AppleVolumes.default. But if I do the same thing with Jane's manifest, it would (I assume) overwrite the file with Jane's copy.

How can I merge both users into the same file gracefully?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-03-31 18:48:41 -0600

GregLarkin gravatar image

From the looks of it, the entries for each user are very similar, so you can probably write your template with an iterator, create your list of users in your .pp file, and the template will be generated as you like.

Here is an example from the docs:

edit flag offensive delete link more

answered 2015-03-31 20:35:16 -0600

lavaman gravatar image

Also, if there's some reason it's not just data, you can use concat and concat fragments:

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-03-31 16:43:08 -0600

Seen: 93 times

Last updated: Mar 31 '15