Forum: CFEngine Help
Subject: How to add to line with field_edits?
Author: marc
Link to topic: https://cfengine.com/forum/read.php?3,22981,22981#msg-22981
Hi List
I have a file with a line like this:
uri server1 server2 server3
What I wanna do is, to check if the line is there. And if it is, check that is
has the right fields.
Something like:
body common control
{
bundlesequence => { "test" };
}
bundle agent test
{
vars:
"serverlist" slist => { "server1", "server2", "server3" };
files:
"/foo/bar"
create => "false",
edit_line => check_and_replace("uri","@(serverlist)");
}
bundle edit_line check_and_replace(match,fields)
{
field_edits:
"$(match).*"
edit_field => col(?????????????)
}
body edit_field col(split,col,newval,method)
{
field_separator => "$(split)";
select_field => "$(col)";
value_separator => ",";
field_value => "$(newval)";
field_operation => "$(method)";
extend_fields => "true";
}
I suppose it is something like this. But I can not figure out how to loop
through me slist, right. And check if the entry in the slist is present and in
the right order, in the "uri" line.
That is not completely true. I can loop through me slist. And end up with this:
uri server1
uri server2
uri server3
But what I want is, if the slist is "server1 server2 server3". Then get this in
me file:
uri server1 server2 server3
Hope you can help :-)
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine