Hi Nicolas,
So I should only be setting like this: bundle edit_line append_if_no_line_set_class(str,class) { insert_lines: "$(str)" classes => satisfied($(class)); } body classes satisfied(new_class) { promise_repaired => { "$(new_class)"}; } Not sure if I understand exactly why that should work. *goes and checks the manual again* Aaah, right. Looks like my understanding was a bit reversed. If the promise was repaired, it set the class to the true, not the way I was thinking it was working, which for some reason was that 'promise_repaired' became a property of the class. (Getting the cfengine 'class' confused with an OOP 'class' at some level, methinks) Which mean the same 'satisfied' definition would work with both code examples? Thank you for your help! Simon From: help-cfengine-boun...@cfengine.org [mailto:help-cfengine-boun...@cfengine.org] On Behalf Of Nicolas Charles Sent: 26 September 2010 20:41 To: help-cfengine@cfengine.org Subject: Re: Restarting a service after a configuration file change. You're code is nearly correct. You just need to set the class if the promise is repaired, not if it's kept. body classes satisfied(new_class) { promise_repaired => { "$(new_class)"}; } Regards, Nicolas On 26/09/2010 21:29, Simon Oxwell wrote: Hi there, I'm running cfengine 3.0.4 on Solaris 10, and I'm trying to build a promise that will append a line to my sshd_config file and then restart the ssh service, but only when the sshd_config has been updated. So far I've tried this: -- Start code bundle agent authorizedkeyfiles { files: "/tmp/sshd_config" edit_line => append_if_no_line("AuthorisedKeyFile /var/ssh/%u"), classes => satisfied("sshd_configuration_altered"); commands: sshd_configuration_altered:: "/usr/sbin/svcadm restart ssh"; } bundle edit_line append_if_no_line(str) { insert_lines: "$(str)" } body classes satisfied(new_class) { promise_kept => { "$(new_class)"}; promise_repaired => { "$(new_class)"}; } -- End code And this: -- Start Code bundle agent authorizedkeyfiles { files: "/tmp/sshd_config" edit_line => append_if_no_line_set_class("AuthorisedKeyFile /var/ssh/%u", "sshd_configuration_altered"); commands: sshd_configuration_altered:: "/usr/sbin/svcadm restart ssh"; } bundle edit_line append_if_no_line_set_class(str,class) { insert_lines: "$(str)" classes => satisfied($(class)); } body classes satisfied(new_class) { promise_kept => { "$(new_class)"}; promise_repaired => { "$(new_class)"}; } -- End Code But they both seem to result in ssh being restarted every time the promise is evaluated. I'm assuming that this is because the "insert_lines" is deemed to be a kept promise if the line to be inserted exists in the file? Is there a way of setting a class to Boolean true only if the file is actually updated? Thanks, Simon -- Simon Oxwell ControlCircle Senior Server Engineer The Datacentre People 0044 (0)20 7517 6594 Hertsmere House, 2 Hertsmere Road, simon.oxw...@controlcircle.com London, E14 4AB _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine
_______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine