Andreas Dvorak
2014-Feb-12 15:14 UTC
[Puppet Users] classe uses two defines but second is ignored
Dear all, ich habe a defined class, that is called two times in on class but only the first call is executed. baader::replace {'access notConfigGroup' is done, but not baader::replace {'com2sec notConfigUser': And baader::replace {'view all included': is done. Can somebody please explain the reason and how can I solve this? define baader::replace($file, $old, $new, $ensure = 'replace') { $grep='/bin/grep' $sed='/bin/sed' case $ensure { default : { err ( "unknown ensure value ${ensure}" ) } replace : { exec { "${sed} -i -e's/${old}/${new}/' '${file}'": unless => "${grep} -qFx '${old}' '${file}'", onlyif => "/usr/bin/test -f '${file}'", } } insert_after : { exec { "${sed} -i -e's/${old}/&\\n${new}/' '${file}'": unless => "${grep} -qFx '${old}' '${file}'", onlyif => "/usr/bin/test -f '${file}'", } } } } class snmp::config{ case $::osfamily { redhat:{ baader::replace {'access notConfigGroup': ensure => 'replace', file => '/etc/snmp/snmpd.conf', old => 'access notConfigGroup \"\" any noauth exact systemview none none', new => 'access notConfigGroup \"\" any noauth exact all none none', } baader::replace {'com2sec notConfigUser': ensure => 'replace', file => '/etc/snmp/snmpd.conf', old => 'com2sec notConfigUser default public', new => 'com2sec notConfigUser default Baad01', } baader::replace {'view all included': ensure => 'insert_after', file => '/etc/snmp/snmpd.conf', old => '# name incl\/excl subtree mask(optional)', new => 'view all included .1', } } ... Best regards Andreas -- 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+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/d095eb0d-3167-4e6d-906a-eab9d7783f83%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.