I use the following in a class:
/etc/puppet/manifests/classes/impuls_test.pp:
$line = 'test'
$tomcatInstances = [ "tc6_a", "tc6_b", "tc6_c", "tc6_d", "tc6_e",
"tc6_f", "tc6_g", "tc6_h", "tc6_i", "tc6_j" ]
tc6conf { $tomcatInstances: }
}
and then the following definition:
/etc/puppet/manifests/classes/definitions.pp:
# Tomcat server.xml.erb und tomcat6.conf.erb shortcut
define tc6conf(owner = root, group = root, mode = 644,
backup = false, recurse = false, ensure = file) {
file { "/tmp/$name-server.xml":
mode => $mode,
owner => $owner,
group => $group,
backup => $backup,
recurse => $recurse,
ensure => $ensure,
content => template("$line/$name/server.xml.erb")
}
file { "/tmp/$name-tomcat6.conf":
mode => $mode,
owner => $owner,
group => $group,
backup => $backup,
recurse => $recurse,
ensure => $ensure,
content => template("$line/$name/tomcat6.conf.erb")
}
}
And matching template files /var/lib/puppet/templates/test/tc6_a/
server.xml.erb or in /etc/puppet/templates/
What it does is it deploys the template files server.xml.erb and
tomcat6.conf for each tomcat to /tmp
So what you get is /tmp/tc6_a-server.xml and /tmp/tc6_a-tomcat6.conf
and so on.
What I also would like to know is how to pass additional parameters to
my defined function, like your $port or $fullserver.
I hope that this helps you in any way.
On Dec 13, 3:01 am, Alex <[email protected]> wrote:
> Hi,
>
> I want to create a single configuration file with one or two
> differences, many times. Therefore, i'd like to do the following in
> pseudo-code:
>
> files = [(a,b), (c,d), (e,f)...]
> foreach a,b in files:
> create_file(a,b)
>
> Which can then use what I think is a valid definition:
> define create_file($port, $fullserver) {
> file { "test.erb":
> content => template('test.erb'),
> }
>
> }
>
> Sadly, it seems that I can not work out either
> a) How to do the "foreach" in the module manifest, to call the defined
> function many times with different paramaters
> b) Where to put the create_file function for puppet to actually
> recognise it. I have tried <moduledir>/plugins/puppet/parser/functions/
> test.rb and <moduledir>/lib/puppet/parser/functions/test.rb, but get
> error "Could not retrieve catalog: Unknown function create_file" on
> the client.
>
> Any suggestions greatly appreciated!
>
> Cheers,
>
> Alex
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.