Ask Your Question
0

2 users 1 template

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

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:192.168.1.1/24
/home/jane/timemachine "Jane's TM on foo" options:tm allow:jane allowed_hosts:192.168.1.1/24

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
2

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

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: https://docs.puppetlabs.com/guides/te...

edit flag offensive delete link more
1

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

lavaman gravatar image

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

https://github.com/puppetlabs/puppetl...

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

Stats

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

Seen: 74 times

Last updated: Mar 31 '15