I figured out what I was doing wrong. I wasn't (maybe I'm still not? :) ) properly taking advantage of the freebie parameter 'title' of defined types. This now seems to behave like I had hoped it would:
class snap::rhel::rh5enable { #... $collector = ['10.0.0.1','10.0.0.2'] #… define add_snmp_hosts_allow () { exec { "hosts_allow_$title": command => "/bin/echo \"snmpd : $title : ALLOW\" >>/etc/hosts.allow", unless => "/bin/grep -c \"snmpd : $title : ALLOW\" /etc/hosts.allow", } }#end define #... notify { "COLLECTOR IS SET TO ${collector}": } add_snmp_hosts_allow{$collector:} #... } notice: /Stage[main]/Snmp::Rhel::Rh5enable/Snmp::Rhel::Rh5enable::Add_snmp_hosts_allow[10.0.0.2]/Exec[hosts_allow_10.0.0.2]/returns: executed successfully notice: COLLECTOR IS SET TO 10.0.0.110.0.0.2 notice: /Stage[main]/Snmp::Rhel::Rh5enable/Notify[COLLECTOR IS SET TO 10.0.0.110.0.0.2]/message: defined 'message' as 'COLLECTOR IS SET TO 10.0.0.110.0.0.2' notice: /Stage[main]/Snmp::Rhel::Rh5enable/Snmp::Rhel::Rh5enable::Add_snmp_hosts_allow[10.0.0.1]/Exec[hosts_allow_10.0.0.1]/returns: executed successfully notice: Finished catalog run in 6.76 seconds On Jul 8, 2012, at 2:38 PM, Wolf Noble wrote: > Hi Eric, > > No, this class is not being called anywhere else. > > What I think is going on is that I have an array of two strings, but somehow > the defined type is getting a concatenated string which contains both values > of the array instead of treating each element of the array as an individual. > > The end goal here is to have an array of each ip address that needs to have > an entry in /etc/hosts.allow, and have a defined type which is fed those IPs > and verifies the presence of/creates the entries as needed. > > is there a better direction to approach this than I'm employing? > > > > > On Jul 8, 2012, at 1:46 PM, Eric Shamow wrote: > >> Wolf, >> >> Are you calling that parameterized class multiple places? >> >> This sounds like a situation where what you want may be a defined type but >> in fact you are using a parameterized class. You can include paramaterized >> classes multiple times using "include" but not using parameters. >> >> -Eric >> >> -- >> >> Eric Shamow >> Professional Services >> http://puppetlabs.com/ >> (c)631.871.6441 >> >> >> On Sunday, July 8, 2012 at 2:00 PM, Wolf Noble wrote: >> >>> Hi gang, >>> >>> I feel like I'm missing something fundamental here… >>> I've got the following: >>> >>> class snmp::rhel::rh5enable { >>> $collector = ['10.0.0.1', '10.0.0.2'] >>> define add_snmp_hosts_allow ($ip) { >>> exec { "hosts_allow_$ip": >>> command => "/bin/echo \"snmpd : $ip : ALLOW\" >>/etc/hosts.allow", >>> unless => "/bin/grep -c \"snmpd : $ip : ALLOW\" /etc/hosts.allow", >>> } >>> } >>> notify { "COLLECTOR IS SET TO ${collector}": } >>> add_snmp_hosts_allow{$collector: ip=> $collector,} >>> } >>> >>> yet I get borked, as : >>> >>> err: Could not retrieve catalog from remote server: Error 400 on SERVER: >>> Duplicate declaration: Exec[hosts_allow_10..0.0.110.0.0.2] is already >>> declared in file >>> /etc/puppetlabs/puppet/modules/core/snmp/manifests/rhel/rh5enable.pp at >>> line 4; cannot redeclare at >>> /etc/puppetlabs/puppet/modules/core/snmp/manifests/rhel/rh5enable.pp:4 on >>> node centos >>> >>> >>> how do I go about doing this "correctly" ? >>> >>> >>> >>> >>> >>> ________________________________ >>> >>> This message may contain confidential or privileged information. If you are >>> not the intended recipient, please advise us immediately and delete this >>> message. See http://www.datapipe.com/legal/email_disclaimer/ for further >>> information on confidentiality and the risks of non-secure electronic >>> communication. If you cannot access these links, please notify us by reply >>> message and we will send the contents to you. >>> >>> -- >>> 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 >>> (mailto:puppet-users@googlegroups.com). >>> To unsubscribe from this group, send email to >>> puppet-users+unsubscr...@googlegroups.com >>> (mailto:puppet-users+unsubscr...@googlegroups.com). >>> For more options, visit this group at >>> http://groups.google.com/group/puppet-users?hl=en. >> >> >> >> -- >> 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+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> > > > ________________________________ > > This message may contain confidential or privileged information. If you are > not the intended recipient, please advise us immediately and delete this > message. See http://www.datapipe.com/legal/email_disclaimer/ for further > information on confidentiality and the risks of non-secure electronic > communication. If you cannot access these links, please notify us by reply > message and we will send the contents to you. > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > ________________________________ This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.