On Monday, December 22, 2014 9:27:47 AM UTC-6, Jonathan Gazeley wrote: > > Hi folks, > > I'm not sure if I'm thinking about the problem the wrong way, but I'm > trying to design a way to have one directory of user information in hiera > which feeds the creation of unix users as well as nagios contacts. I have a > hiera data structure like this: > > unifiedusers: > jon: > nagiosuser: true > comment: Jonathan > gid: resnet > uid: 56933 > sudo: true > groups: > - resnet > - superadmins > paul: > nagiosuser: true > comment: Paul > gid: resnet > uid: 23770 > sudo: true > groups: > - resnet > - superadmins > dave: > nagiosuser: false > comment: Dave > gid: networks > uid: 1234 > sudo: false > groups: > - resnet > > I have code that works well to create unix users & groups. I'm struggling > more with nagios stuff. Ideally I want to end up with an array of usernames > for whom nagiosuser==true. So my array @nagiosusers would contain ['jon', > 'paul'] but not 'dave'. Is this possible? > >
Of course it's possible. Puppet has enough hooks that you can plug in any kind of data transformation you want. Puppet does not have a *direct* solution to this particular problem, however. It would be cleanest to write a custom function to do what this job, but it would be quicker to do it with an inline template (which you can consider a proof of concept for that function) something like this: $nagios_users_string = inline_template("<%= @unifiedusers.select { |k, v| v['nagiosuser'] }.keys.join(',') %>") $nagios_users = split($nagios_users_string, ',') John -- 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/cbb81fb4-7023-4154-9810-ba81417f2751%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.