I'd like to add a "this file managed by puppet" line to the top of the files I manage with augeas.
This works but is not idempotent. I could add an onlyif but then if I want to change SELINUX to "off" I won't be able to, since the comment will always exist.
augeas { 'selinux_config':
context => '/files/etc/selinux/config',
changes => [
'ins #comment before #comment[1]',
'set #comment[1] "TEST"',
'set SELINUX on',
],
}
I I tried the following but get error "Error: /Stage[main]/Test_module/Augeas[selinux_config]: Could not evaluate: Saving failed, see debug"
If I remove the 'ins' line the comment is added and it's idempotent, but of course the comment is at the bottom of the file.
augeas { 'selinux_config':
context => '/files/etc/selinux/config',
changes => [
'ins #comment before #comment[1]',
'set #comment[. = "TEST" ] "TEST"',
'set SELINUX on',
],
}
Is there any way to get this to work or am I just beating my head against the wall for nothing?