You should try the current version. 3.0.4 will be released in March
Henning Fehrmann wrote:
> Hello,
>
> we tried to use cfengine3 v3.0.2 to update our /etc/passwd.
>
> The promises.cf reads:
>
> body common control
> {
> bundlesequence => {
> "handle_passwd"
> };
> inputs => {
> "passwd.cf"
> };
> }
>
> body agent control
> {
> ifelapsed => "0";
> }
>
> body monitor control
> {
> forgetrate => "0.7";
> histograms => "true";
> }
>
> body executor control
>
> {
> splaytime => "1";
> mailto => "a...@b";
> smtpserver => "smtpserver";
> mailmaxlines => "30";
> exec_command => "$(sys.workdir)/bin/cf-agent -f failsafe.cf
> && $(sys.workdir)/bin/cf-agent";
> }
>
> body reporter control
> {
> reports => { "performance", "last_seen", "monitor_history" };
> build_directory => "/tmp/log";
> report_output => "html";
> }
>
> The passwd.cf is:
>
> bundle agent handle_passwd
> {
> vars:
> ipv4_10::
> "file_new" string =>
> "/var/cfengine/inputs/passwd_new";
> "file_obsolete" string =>
> "/var/cfengine/inputs/passwd_obsolete";
> "newlines"
> slist => {
> readstringlist($(file_new),"#.*","",2048,65536) };
> "obsolete"
> slist => {
> readstringlist($(file_obsolete),"#.*","",2048,65536) };
>
> files:
> ipv4_10::
> "/var/cfengine/inputs/passwd"
> edit_line => addline($(newlines)),
> comment => "add new lines",
> action => immediate;
>
> "/var/cfengine/inputs/passwd"
> edit_line => remove($(obsolete)),
> comment => "removed obsolete users $(obsolete)",
> action => immediate;
>
> reports:
> ipv4_10::
> "passwd updated";
> }
>
>
> bundle edit_line addline(newline)
> {
> insert_lines:
> "$(newline)";
>
> }
>
> bundle edit_line remove(obsolete)
> {
> delete_lines:
> "$(obsolete):.*";
> }
>
>
>
> We start with the following /var/cfengine/inputs/passwd:
> org:a:b:c
> obs:a:b:c
>
> /var/cfengine/inputs/passwd_obsolete:
> obs
>
> and
> /var/cfengine/inputs/passwd_new:
> new:a:b:c
>
> After launching 'cf-agent -v -f /tmp/promises.cf' I get for the
> /var/cfengine/inputs/passwd:
> org:a:b:c
> obs:a:b:c
> new:a:b:c
>
>
> Apparently the deletion of the 'obs:.*' line failed. There is also an empty
> line after the 'new:a:b:c' line.
>
> Here are some snippets of the verbose output:
>
> :
> cf3 .........................................................
> cf3
> cf3 -> This promise has already been verified
> cf3 -> Saving edit changes to file /var/cfengine/inputs/passwd
> cf3 Edited file /var/cfengine/inputs/passwd
> cf3
> cf3 .........................................................
> cf3 Promise handle:
> cf3 Promise made by: /var/cfengine/inputs/passwd
> cf3
> cf3 Comment: removed obsolete users obs
> cf3 .........................................................
> cf3
> cf3 -> Using literal pathtype for /var/cfengine/inputs/passwd
> cf3 -> Handling file existence constraints on /var/cfengine/inputs/passwd
> cf3 -> Handling file edits in edit_line bundle remove
> cf3
> cf3 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> cf3 BUNDLE remove( {'obs
> '} )
> cf3 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> cf3
> cf3 ? Augment scope remove with obsolete
> cf3 ?? Private class context
> cf3
> cf3
> cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> cf3 delete_lines in bundle remove
> cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> cf3
> cf3
> cf3 .........................................................
> cf3 Promise handle:
> cf3 Promise made by: obs
> :.*
> cf3 .........................................................
> cf3
> cf3 ?? Private class context
> cf3
> cf3
> cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> cf3 delete_lines in bundle remove
> cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> cf3
> cf3
> cf3 .........................................................
> cf3 Promise handle:
> cf3 Promise made by: obs
> :.*
> cf3 .........................................................
> cf3
> cf3 -> This promise has already been verified
> cf3 ?? Private class context
> cf3
> cf3
> cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> cf3 delete_lines in bundle remove
> cf3 = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> cf3
> cf3
> cf3 .........................................................
> cf3 Promise handle:
> cf3 Promise made by: obs
> :.*
> cf3 .........................................................
> cf3
> cf3 -> This promise has already been verified
> cf3 -> No edit changes to file /var/cfengine/inputs/passwd need saving
> cf3
> cf3 =========================================================
> cf3 reports in bundle handle_passwd (1)
> cf3 =========================================================
> cf3
> cf3 Verifying SQL table promises is only available with Cfengine Nova or above
> cf3
> cf3 .........................................................
> cf3 Promise handle:
> cf3 Promise made by: passwd updated
> cf3 .........................................................
> cf3
> cf3 R: passwd updated
> cf3
> cf3 + Private classes augmented:
> cf3
> cf3 - Private classes diminished:
> cf3
> cf3
> cf3
> cf3 =========================================================
> cf3 files in bundle handle_passwd (2)
> cf3 =========================================================
> :
> cf3
> cf3 Verifying SQL table promises is only available with Cfengine Nova or above
> cf3 Outcome of version (not specified) (agent-0): Promises observed to be
> kept 33%, Promises repaired 67%, Promises not repaired 0%
>
>
> There are strange line breaks like
> cf3 Promise made by: obs
> :.*
>
> Do you have an idea why the the 'obs' lines are not deleted?
>
> Thank you.
>
> Cheers,
> Henning
>
> _______________________________________________
> Help-cfengine mailing list
> [email protected]
> https://cfengine.org/mailman/listinfo/help-cfengine
--
Mark Burgess
-------------------------------------------------
Professor of Network and System Administration
Oslo University College, Norway
Personal Web: http://www.iu.hio.no/~mark
Office Telf : +47 22453272
-------------------------------------------------
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine