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