Hi all, One of my facter variables returns an array of disks presently connected to the system. I want to have something in my manifest that loops around the array and adds a Nagios check for each disk. In perlish pseudocode, I imagine something like this: @disks = sda,sdb,sdc foreach $disk in @disks { @@nagios_service { "check_disk_${disk}": check_command => "check_disk!${disk}", host_name => "$fqdn", service_description => "Disk ${disk} status", } } From what I can gather, a straightforward foreach isn''t possible in puppet 2.6.6. Is there a workaround or a better way of achieving this? Thanks, Jonathan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
----- Original Message -----> Hi all, > > One of my facter variables returns an array of disks presently > connected > to the system. I want to have something in my manifest that loops > around > the array and adds a Nagios check for each disk. > > In perlish pseudocode, I imagine something like this: > > @disks = sda,sdb,sdc > > foreach $disk in @disks { > @@nagios_service { "check_disk_${disk}": > check_command => "check_disk!${disk}", > host_name => "$fqdn", > service_description => "Disk ${disk} status", > } > } > > From what I can gather, a straightforward foreach isn''t possible in > puppet 2.6.6. Is there a workaround or a better way of achieving > this?If you made a defined type you can do it. here''s a very simple one that loops an array and create ''notify'' resources: define print { notify{"the message is: ${name}": } } print{["one", "two", "three"]: } this would be the same as making these resources by hand: notify{"the message is: one": } notify{"the message is: two": } notify{"the message is: three": } -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
R.I.Pienaar:> here''s a very simple one that loops an array and create ''notify'' > resources: > define print { notify{"the message is: ${name}": } } > print{["one", "two", "three"]: }Strictly speaking, this isn''t really "looping" on the array so much as "mapping" on the array (there may be a more specific term out there in FP-land). There ought to be no guarantee of the order in which these notifies are realized, and the only promised result should be that each element will be realized exactly once before the operation on the array has completed. Nit-picky, I know, but it''s important to avoid procedural language when discussing a declarative system. -- You are in an open field west of a big white house with a boarded front door. There is a small mailbox here.> _-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.