Hi dear,

Very thanks!

Em qui, 16 de fev de 2017 às 18:09, Henrik Lindberg <
henrik.lindb...@puppet.com> escreveu:

> 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 puppet-users+unsubscr...@googlegroups.com
> > <mailto: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
> > <
> 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 puppet-users+unsubscr...@googlegroups.com.
> 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.
>
-- 
Atenciosamente,
Rafael Tomelin
skype: rafael.tomelin
E-mail: rafael.tome...@gmail.com

RHCE - Red Hat Certified Engineer
Zabbix - ZABBIX Certified Specialist
LPI3
ITIL v3

-- 
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/CAGEUqbC6Qy9xrkN18GjB4Ejn5Qz3yMjid%2BV5fGERxJBu56HJ6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to