Forum: CFEngine Help
Subject: Re: On persistent classes
Author: sauer
Link to topic: https://cfengine.com/forum/read.php?3,24095,24148#msg-24148
The classes body applies to all promise types, including class promises, right?
I wonder what happens if you just specify a persist_time attribute in a
classes compound body, and use that in a class promise? :)
So I tried with this little bit of demo code, and it does't appear that the
classes attribute is actually used for a class promise. :/ I'd think that
specifying a persist_time ( perhaps with a promise_kept => "$(this.promiser)" )
would be the way this should work. But it seemingly does not work that way.
#!/var/cfengine/bin/cf-agent -Kf
body common control{ bundlesequence => { "a" }; }
bundle agent a {
vars:
true:: "cmd" string => "/bin/true";
false:: "cmd" string => "/bin/false";
classes:
any::
"controlclasst" expression => returnszero("/bin/true", "noshell");
"controlclassf" expression => returnszero("/bin/false", "noshell");
"transientclass" expression => returnszero("$(cmd)", "noshell");
"persistclass" expression => returnszero("$(cmd)", "noshell"),
classes => stickaround;
reports:
linux|!linux:: "Command is '$(cmd)'";
controlclasst:: "True control is working.";
controlclassf:: "False control is not working.";
transientclass:: "Transient class is set";
persistclass:: "Persistent class is set";
persist:: "stickaround was called";
persistclass&!persist:: "stickaround was apparently not called";
}
body classes stickaround {
persist_time => "2";
timer_policy => "reset";
promise_kept => { "$(this.promiser)", "persist" };
promise_repaired => { "$(this.promiser)", "persist" };
repair_failed => { "persist" };
repair_denied => { "persist" };
repair_timeout => { "persist" };
}
$ ./persist.cf -Dtrue
R: Command is '/bin/true'
R: True control is working.
R: Transient class is set
R: Persistent class is set
R: stickaround was apparently not called
$ ./persist.cf -Dfalse
R: Command is '/bin/false'
R: True control is working.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine