Greetings,

I have a question about setting ifelapsed to 0 for certain promises.
Consider this code.  The goal is to repair a service config file.  If
this happens stop the service.  It is my hope on the final run the
processes promise will note that the process is missing and thus case
the commands promise to start the service.

I know a separate promise for restarting is more conventional but I'm
hoping to avoid that.  It is not uncommon to find services that have no
restart function.  Also because 'I can'.  So I'm hoping that this will
work.  It's close but not quite.

On the first run the config file is repaired.  On the second run the
stop command is run.  On the third run it was my hope that the processes
promise would note the lack of a running process and set a class for
the final commands promise to start the service.  What actually happens
on the is the agent states that the processes promise has already been
verified. What have I misunderstood? 

processes:

         "${g.svc_proc[${service}]}",
             action => immediate,
             comment => 
                 "Search for running process for service ${service}",
             restart_class => 
                 canonify("${service}_proc_missing");

commands:

     "${g.svc_stop[${service}]}",
         ifvarclass => canonify("${g.svc_trg[${service}]}_copy_repaired"),
         classes => cdefine(
             "${g.svc_start[${service}]}_kept",
             "${g.svc_start[${service}]}_stopped",
             "${g.svc_start[${service}]}_failed"
             ),
         comment => 
             "Start $(service) if ${g.svc_trg[${service}]} changed.";

     "${g.svc_start[${service}]}",
         ifvarclass => canonify("${service}_proc_missing"),
         action => immediate,
         classes => cdefine(
             "${g.svc_start[${service}]}_kept",
             "${g.svc_start[${service}]}_started",
             "${g.svc_start[${service}]}_failed"
             ),
         comment => 
             "Start $(service) if proc ${g.svc_proc[${service}]} not running.";

body action immediate
{
ifelapsed => "0";
}

-- 
Neil Watson
Linux/UNIX Consultant
http://watson-wilson.ca
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to