Forum: CFEngine Help
Subject: Using the new services promise types with Linux's chkconfig
Author: msvob...@linkedin.com
Link to topic: https://cfengine.com/forum/read.php?3,26785,26785#msg-26785

I'm converting UNIX services over from a policy that I had written that 
utilized "process" and "commands" promise types over to the "services" 
framework that was introduced in Cfengine 3.3.X.

Here's an example in a policy:


services:
        cfengine_administrated_nfs_servers::
                "nfs"
                        service_policy          =>      "start",
                        service_method          =>      bootstart;





In my standard_services.cf bundle that shows how to start / stop the NFS 
process:


$ cat standard_services.cf 
bundle agent standard_services(service, state)
{
vars:
        linux::
                "startcommand"          string  =>      "/etc/init.d/httpd 
start";
                "stopcommand"           string  =>      "/etc/init.d/httpd 
stop";
                "processname"           string  =>      "httpd";

                "startcommand"          string  =>      "/etc/init.d/nfs start";
                "stopcommand"           string  =>      "/etc/init.d/nfs stop";
                "processname"           string  =>      "nfsd";
        
classes:
        "start" expression => strcmp("start","$(state)");
        "stop" expression => strcmp("stop","$(state)");

processes:
        start::
                ".*$(processname[$(service)]).*"
                        comment => "Verify that the service appears in the 
process table",
                        restart_class => "restart_$(service)";
        stop::
                ".*$(processname[$(service)]).*"
                        comment => "Verify that the service does not appear in 
the process table",
                        process_stop => "$(stopcommand[$(service)])",
                        signals => { "term", "kill"};
commands:
   "$(startcommand[$(service)])"
         comment => "Execute command to restart the $(service) service",
         ifvarclass => "restart_$(service)";
}




And finally my cfengine_stdlib.cf which shows the "service_method" body promise 
for bootstart.


############################################
body service_method bootstart
{
service_autostart_policy => "boot_time";
service_dependence_chain => "start_parent_services";
}




So, my question is -- how do we define the "service_method boostart" body to 
actually configure chkconfig to start this service at boot time?  Is this 
hard-coded in the Cfengine code to "chkconfig --add " and "chkconfig  on" or 
does this need to be manually defined somewhere?


My policy works on bringing the service online, but chkconfig still shows it 
disabled at boot time.

Shutting down NFSD and verifying that the promise brings NFSD back up.



# /etc/init.d/nfs stop
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS quotas:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]


# /var/cfengine/bin/cf-agent -I -K -b manage_linux_nfs_servers
 >> Using command line specified bundlesequence
 -> Making a one-time restart promise for .*nfsd.*
 -> Executing '/etc/init.d/nfs start' ...(timeout=-678,owner=-1,group=-1)
Q: "...init.d/nfs star": Starting NFS services:            [  OK  ]
Q: "...init.d/nfs star": Starting NFS quotas:              [  OK  ]
Q: "...init.d/nfs star": Starting NFS daemon:              [  OK  ]
Q: "...init.d/nfs star": Starting NFS mountd:              [  OK  ]
I: Last 4 quoted lines were generated by promiser "/etc/init.d/nfs start"
 -> Completed execution of /etc/init.d/nfs start

# /var/cfengine/bin/cf-agent -I -K -b manage_linux_nfs_servers
 >> Using command line specified bundlesequence




But chkconfig still shows the service not starting at boot


# chkconfig --list | grep nfs
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off



Any suggestions?

Thanks!
Mike

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

Reply via email to