On 07/24/2014 08:08 PM, senorsmile wrote:
> For example, I have an array like this:
>
> clusters => [
> 'cluster1',
> 'cluster2',
> 'cluster3',
> 'cluster4',
> ]
>
>
>
> I then have a cluster.init.erb that looks soemthing like this:
>
> start on runlevel [2345]
> stop on runlevel [!2345]
>
> expect fork
> respawn
>
> <% @clusters.each do | cluster | -%>
> env PIDFILE="/var/run/${cluster}.pid"
>
> exec /usr/sbin/program_name --pid-file=$PIDFILE
> <% end -%>
>
>
> That is all theoretical at this point since it doesn't work.
> What I need it to do is dynamically generate a certain number of files,
> equal to the number of files in the array "clusters", whose names I will
> not know beforehand, and changes from host to host.
>
You could create a define that would be an intermediate layer. Code
would look like the following :
Manifest
--------
$clusters = ['cluster1', 'cluster2', 'clustern']
myclass::mydefine {$clusters : }
Define
------
class myclass::mydefine {
$path = "/tmp/${name}"
file { $path :
ensure => present,
content => template('myclass/foo.erb'),
}
}
Template
--------
Find my value <%= @name %>
Hope this helps,
--
Yanis Guenane
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/53D2621B.80205%40gmail.com.
For more options, visit https://groups.google.com/d/optout.