using template to populate a dir.

77 views
Skip to first unread message

Evan Hisey

unread,
Apr 11, 2008, 6:38:00 PM4/11/08
to puppet...@googlegroups.com
I have started using templates to manage all my text config files.
First and unexpected benefit has the been sudden reduction of things I
need to back up, probably should have been obvious but I did not
expect it. This leads to a question I have not found an answer for,
can you use a template to populate a dir with multiple files?
Currentlly I have about 10 files under /etc/profile.d that need to be
managed each file is really small, but the programs want there own
profile file.
Solution A is use the puppet fileserver and server out the
directory, I am not fond of htis one do to permission and recurse, but
it works

Solution B use either a template per file or server each file out
fomr teh server in its own File[]. Again works but the overhead
outweighs the gain.

Solution C use a single template to create all the files in the dir.I
could do this using a single template and File{$name:} type call to
walk an array to create each file from the template. Already using
something like this for automount maps. What I am hoping I could do
is something like this

file{"profile.d":
path => "/etc/profile.d"
content => tempalte(profiled.erb)
}

and have the template create each of the files. It may not be
possible. Just thought I would ask before I tried to make the
impossible work.

Evan

David Schmitt

unread,
Apr 12, 2008, 4:12:40 AM4/12/08
to puppet...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 12 April 2008, Evan Hisey wrote:
> I have started using templates to manage all my text config files.
> First and unexpected benefit has the been sudden reduction of things I
> need to back up, probably should have been obvious but I did not
> expect it. This leads to a question I have not found an answer for,
> can you use a template to populate a dir with multiple files?
> Currentlly I have about 10 files under /etc/profile.d that need to be
> managed each file is really small, but the programs want there own
> profile file.

Depending on your detailled needs, you might be able to nail that down by
using a define:

define profile_d($param1, $param2) {
file { "/etc/profile.d/${name}":
source => template("${name}.erb")
}
}

profile_d {
[ 'app1', 'app2' ] : param1 => value1, param2 => value2;
'app3' : param1 => value3, param2 => value4;
}

Regards, DavidS

- --
The primary freedom of open source is not the freedom from cost, but the free-
dom to shape software to do what you want. This freedom is /never/ exercised
without cost, but is available /at all/ only by accepting the very different
costs associated with open source, costs not in money, but in time and effort.
- -- http://www.schierer.org/~luke/log/20070710-1129/on-forks-and-forking
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIAG77/Pp1N6Uzh0URAgMOAJ9A0LbnTW0Av5irumh15PvlBU8lnwCghEs8
cJ0FOGBU4X7FPTvX/3rDjwA=
=TJQ1
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages