Forum: Cfengine Help
Subject: Re: conditional command execution
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,20520,20521#msg-20521

Cf-agent only copies if the target file is out of date.  It does not do any 
redundant work.  You do not have to worry about making your own logic for this.

To make the agent restart sshd if the file is updated you want to set a class 
if the promise is repaired.  For example:
    files:
    
        ntp_all::
            "/etc/ntp.conf"
                comment =>  "Manage ntp config file.",
                perms => system("0644","root","0"),
                copy_from => mycopy("${g.masterfiles}/config/ntp.conf"),
                classes => cdefine( "ntp_config_update", "ntp_config_failed");

    processes:

        ntp_all::
            "ntpd"
                comment => "Check for the required ntp processes.",
                restart_class => canonify("ntp_proc_missing");

    commands:

        ntp_config_update|ntp_proc_missing::
            "/etc/init.d/ntpd restart", 
            action => xfix,
            classes => cdefine( "ntp_start", "ntp_start_failed"),
            comment => "Restart ntp if required";
    


_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to