Forum: CFEngine Help
Subject: edit_lines with regex promiser does not work
Author: svenXY
Link to topic: https://cfengine.com/forum/read.php?3,24906,24906#msg-24906
This has been brought up more than once.
I understand (partly) that depth_search and edit_lines are a big thing (why,
actually?), but the reference proposes that
body common control
{
bundlesequence => { "testbundle" };
}
########################################################
bundle agent testbundle
{
files:
"/tmp/test/.*"
edit_line => add_line;
}
bundle edit_line add_line
{
insert_lines:
"this line should be there";
}
should work.
It does not, actually:
$ touch /tmp/test/{a,b,c}.txt
$ ls -l /tmp/test/
insgesamt 0
-rw-rw-r--. 1 svenh svenh 0 17. Feb 16:02 a.txt
-rw-rw-r--. 1 svenh svenh 0 17. Feb 16:02 b.txt
-rw-rw-r--. 1 svenh svenh 0 17. Feb 16:02 c.txt
$ cf-agent -I -f ./testme.cf
Couldn't find a private key (/home/svenh/.cfagent/ppkeys/localhost.priv) - use
cf-key to get one
!!! System error for fopen: "No such file or directory"
-> Edited file /tmp/test/a.txt
$ ls -l /tmp/test/
insgesamt 4
-rw-rw-r--. 1 svenh svenh 26 17. Feb 16:02 a.txt
-rw-rw-r--. 1 svenh svenh 0 17. Feb 16:02 a.txt.cf-before-edit
-rw-rw-r--. 1 svenh svenh 0 17. Feb 16:02 b.txt
-rw-rw-r--. 1 svenh svenh 0 17. Feb 16:02 c.txt
As pointed out in various locations here and in the bugtracker, only one file
(here: a.txt) is ever edited.
I can see no workaround here, as in my case, I'm trying to edit files under
/etc/logrotate.d where application packages (rpm) drop their logrotation
policies and I do not always know which ones are present.
I'd like to second my fellow posters who have to cope with similar problems.
Can this please be made possible somehow?
Thanks,
Sven
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine