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?


-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/b76ca740-d7f6-4dd6-8079-43bc72700c06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to