On 13/02/17 18:05, Rafael Tomelin wrote:
Hi dear,I is create a module and need loop in puppet class and template The my class step is: 1) My class have array declared; $pools = [ { name => 'PoolDiario', poolType => 'Backup', recycle => 'yes', autoPrune => 'yes', volumeRetention => '30 days', maximumVolumeBytes => '1G', maximumVolumes => '100', labelFormat => 'Local-' } , { name => 'PoolDiario2', poolType => 'Backup2', recycle => 'yes', autoPrune => 'yes', volumeRetention => '20 days', maximumVolumeBytes => '5G', maximumVolumes => '10', labelFormat => 'Local2' } ]) 2) The array is create file; example: count array$pools $teste = $pools[COUNT]['name'] #LOOP file { "/etc/bacula/pool/pool_$teste.conf": ensure => 'file', owner => 'bacula', group => 'bacula', content => template('bacula/director/pool_conf.erb') } 3) Template loop get array. Pool { <% pools.each do |pool| -%> Name = "<%= pool['name'] %>" Pool Type = "<%= pool['poolType'] %>" Recycle = <%= pool['recycle'] %> AutoPrune = <%= pool['autoPrune'] %> Volume Retention = "<%= pool['volumeRetention'] %>" Maximum Volume Bytes = "<%= pool['maximumVolumeBytes'] %>" Maximum Volumes = <%= pool['maximumVolumes'] %> Label Format = "<%= pool['labelFormat'] %>" <% end -%> } But this create Pool to array. I can make this module?
Puppet 4.x (and puppet 3.x with future parser) supports iteration with functions such as each, map, reduce (and many more). That should enable you to do what you want.
- henrik
-- 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] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/b76ca740-d7f6-4dd6-8079-43bc72700c06%40googlegroups.com <https://groups.google.com/d/msgid/puppet-users/b76ca740-d7f6-4dd6-8079-43bc72700c06%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout.
-- Visit my Blog "Puppet on the Edge" http://puppet-on-the-edge.blogspot.se/ -- 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/0554267c-29cc-5bda-a6b2-2df9f1c9dc82%40puppet.com. For more options, visit https://groups.google.com/d/optout.
