Stuck trying to iterate through a hiera array

17 views
Skip to first unread message

Ryan Murphy

unread,
Jul 21, 2017, 3:21:22 PM7/21/17
to Puppet Users
So my hiera variable looks like this.

contacts:
   'Group A':
      'bmurphy': 'bobm...@testsite.com'
      'cjames':  'chad...@testsite.com'
   'Group B':
      'RPrice': 'RodP...@testsite.com'
      'STurpen': 'Steve...@testsite.com'


I need to be able to iterate through contacts, grab the group name create a Nagios_contact group based on that value, then iterate through each group and create the contacts.  How do I do this?

I tried something like below but it just doesn't work.

  $contactdata.each | $groupname, $groupcontacts | {
    $contactgroupname = $groupname[0]
    nagios_contactgroup { "$contactgroupname":
      ensure => present,
    }
    $groupcontacts.each | String $username, String $emailaddress | {
      nagios_contact { "$username":
        ensure        => present,
        contactgroups => "$groupdisplay",
        email         => "$emailaddress",
      }
    }

Ryan Murphy

unread,
Jul 21, 2017, 3:23:50 PM7/21/17
to Puppet Users
The [0] after groupname shouldn't be there.  Still didn't work 

Ryan Murphy

unread,
Jul 21, 2017, 3:38:29 PM7/21/17
to Puppet Users
Apparently I had another mistype somewhere.  Problem solved.


On Friday, July 21, 2017 at 2:21:22 PM UTC-5, Ryan Murphy wrote:
Reply all
Reply to author
Forward
0 new messages