Forum: CFEngine Help Subject: service policy not working Author: skel84 Link to topic: https://cfengine.com/forum/read.php?3,27396,27396#msg-27396
HI, i'm having a strange issue with a service policy. Here's the bundle: ##################################################################### body common control { bundlesequence => { "service_catalogue" }; } bundle agent service_catalogue { services: aix|(linux.!log):: "ntp" service_policy => "start"; "nrpe" service_policy => "start"; "ssh" service_policy => "start"; "syslog" service_policy => "start"; nim:: "tftp" service_policy => "start"; "nfs" service_policy => "start"; } bundle agent standard_services(service,state) { vars: linux:: "startcommand" string => "/etc/init.d/ntpd start"; "stopcommand" string => "/etc/init.d/ntpd stop"; "reloadcommand" string => "/etc/init.d/ntpd restart"; "processname" string => "ntpd"; "startcommand" string => "/etc/init.d/nrpe start"; "stopcommand" string => "/etc/init.d/nrpe stop"; "reloadcommand" string => "/etc/init.d/nrpe restart"; "processname" string => "nrpe"; "startcommand" string => "/etc/init.d/sshd start"; "stopcommand" string => "/etc/init.d/sshd stop"; "reloadcommand" string => "/etc/init.d/sshd restart"; "processname" string => "sshd"; redhat_4|redhat_5:: "startcommand" string => "/etc/init.d/syslog start"; "stopcommand" string => "/etc/init.d/syslog stop"; "reloadcommand" string => "/etc/init.d/syslog restart"; "processname" string => "syslogd"; redhat_6:: "startcommand" string => "/etc/init.d/rsyslog start"; "stopcommand" string => "/etc/init.d/rsyslog stop"; "reloadcommand" string => "/etc/init.d/rsyslog restart"; "processname" string => "rsyslogd"; aix:: "startcommand" string => "/usr/bin/startsrc -s xntpd"; "stopcommand" string => "/usr/bin/stopsrc -s xntpd"; "reloadcommand" string => "/usr/bin/refresh -s xntpd"; "processname" string => "xntpd"; "startcommand" string => "/usr/bin/startsrc -s sshd"; "stopcommand" string => "/usr/bin/stopsrc -s sshd"; "reloadcommand" string => "/usr/bin/refresh -s sshd"; "processname" string => "sshd"; "startcommand" string => "/usr/bin/startsrc -s syslogd"; "stopcommand" string => "/usr/bin/stopsrc -s syslogd"; "reloadcommand" string => "/usr/bin/refresh -s syslogd"; "processname" string => "syslogd"; "startcommand" string => "/mgmt/sys/scripts/nrpe_cmd.sh start"; "stopcommand" string => "/mgmt/sys/scripts/nrpe_cmd.sh stop"; "reloadcommand" string => "/mgmt/sys/scripts/nrpe_cmd.sh restart"; "processname" string => "nrpe"; nim:: "startcommand" string => "/usr/bin/startsrc -s tftpd"; "stopcommand" string => "/usr/bin/stopsrc -s tftpd"; "reloadcommand" string => "/usr/bin/refresh -s tftpd"; "processname" string => "tftpd"; "startcommand" string => "/usr/bin/startsrc -s nfsd"; "stopcommand" string => "/usr/bin/stopsrc -s nfsd"; "reloadcommand" string => "/usr/bin/refresh -s nfsd"; "processname" string => "nfsd"; classes: "start" expression => strcmp("start","$(state)"); "stop" expression => strcmp("stop","$(state)"); processes: start:: ".*$(processname[$(service)]).*" handle => "sys_procs_$(service)_start", comment => "Verify that the service appears in the process table", restart_class => "restart_$(service)"; stop:: ".*$(processname[$(service)]).*" handle => "sys_aix_procs_$(service)_stop", comment => "Verify that the service does not appears in the process table", process_stop => "$(stopcommand[$(service)])", signals => { "term", "kill"}; commands: "$(startcommand[$(service)])" handle => "sys_procs_$(service)_start", comment => "Execute command to start the $(service) service", ifvarclass => "restart_$(service)"; "$(reloadcommand[$(service)])" handle => "sys_procs_$(service)_restart", comment => "Execute command to restart the $(service) service", ifvarclass => canonify("reload_$(service)"); } ########################################################################### And the output: ################################ cf3> Cfengine - autonomous configuration engine - commence self-diagnostic prelude cf3> ------------------------------------------------------------------------ cf3> Work directory is /var/cfengine cf3> Making sure that locks are private... cf3> Checking integrity of the state database cf3> Checking integrity of the module directory cf3> Checking integrity of the PKI directory cf3> Looking for a source of entropy in /var/cfengine/randseed cf3> -> Loaded private key /var/cfengine/ppkeys/localhost.priv cf3> -> Loaded public key /var/cfengine/ppkeys/localhost.pub cf3> Setting cfengine default port to 5308 = 5308 cf3> Reference time set to Mon Sep 17 19:16:34 2012 cf3> CFEngine Core 3.2.1 cf3> ------------------------------------------------------------------------ cf3> Host name is: uatlxrep03 cf3> Operating System Type is linux cf3> Operating System Release is 2.6.32-202.el6.i686 cf3> Architecture = i686 cf3> Using internal soft-class linux for host uatlxrep03 cf3> The time is now Mon Sep 17 19:16:34 2012 cf3> ------------------------------------------------------------------------ cf3> # Extended system discovery is only available in version Nova and above cf3> Additional hard class defined as: 32_bit cf3> Additional hard class defined as: linux_2_6_32_202_el6_i686 cf3> Additional hard class defined as: linux_i686 cf3> Additional hard class defined as: linux_i686_2_6_32_202_el6_i686 cf3> GNU autoconf class from compile time: compiled_on_linux_gnu cf3> Address given by nameserver: 10.218.136.118 cf3> Interface 1: lo cf3> Interface 2: eth0 cf3> Trying to locate my IPv6 address cf3> Looking for environment from cf-monitord... cf3> Loading environment... cf3> Environment data loaded cf3> This appears to be a redhat (or redhat-based) system. cf3> Looking for redhat linux info in "Red Hat Enterprise Linux Server release 6.2 Beta (Santiago)" cf3> *********************************************************** cf3> Loading persistent classes cf3> *********************************************************** cf3> Persistent class cfengine_out_high_ldt for 9 more minutes cf3> Adding persistent class cfengine_out_high_ldt to heap cf3> *********************************************************** cf3> Loaded persistent memory cf3> *********************************************************** cf3> -> Found a policy server (hub) on 10.218.251.201 cf3> -> Input file is outside default repository, validating it cf3> -> Promises seem to change cf3> -> Input file is changed since last validation, validating it cf3> -> Verifying the syntax of the inputs... cf3> Checking policy with command ""/var/cfengine/bin/cf-promises" -f "./services.cf"" cf3> -> Caching the state of validation cf3> > Parsing file ./services.cf cf3> Initiate variable convergence... cf3> Initiate variable convergence... cf3> # Knowledge map reporting feature is only available in version Nova and above cf3> -> Defined classes = { 10_218_136_118 32_bit Day17 Evening GMT_Hr17 Hr19 Hr19_Q2 Lcycle_2 Min15_20 Min16 Monday PK_MD5_90066edab468047c36cf333efdccdaff Q2 September Yr2012 agent any cbdom_it cfengine cfengine_3 cfengine_3_2 cfengine_3_2_1 cfengine_out_high_ldt community_edition compiled_on_linux_gnu diskfree_high_normal entropy_cfengine_in_low entropy_dns_in_low entropy_dns_out_low entropy_ftp_in_low entropy_ftp_out_low entropy_icmp_in_low entropy_icmp_out_low entropy_irc_in_low entropy_irc_out_low entropy_misc_in_low entropy_misc_out_low entropy_netbiosdgm_in_low entropy_netbiosdgm_out_low entropy_netbiosns_in_low entropy_netbiosns_out_low entropy_netbiosssn_in_low entropy_netbiosssn_out_low entropy_nfsd_in_low entropy_nfsd_out_low entropy_smtp_in_low entropy_smtp_out_low entropy_ssh_out_low entropy_tcpack_in_low entropy_tcpack_out_low entropy_tcpfin_in_low entropy_tcpfin_out_low entropy_tcpsyn_in_low entropy_tcpsyn_out_low entropy_udp_in_low entropy_udp_out_low entrop y_www_in_low entropy_www_out_low entropy_wwws_in_low entropy_wwws_out_low i686 ipv4_10 ipv4_10_218 ipv4_10_218_136 ipv4_10_218_136_118 it linux linux_2_6_32_202_el6_i686 linux_i686 linux_i686_2_6_32_202_el6_i686 linux_i686_2_6_32_202_el6_i686__1_SMP_Wed_Sep_21_15_26_29_EDT_2011 messages_high_normal net_iface_eth0 redhat redhat_6 redhat_6_2 redhat_s redhat_s_6 redhat_s_6_2 rootprocs_high_normal uatlxrep03 uatlxrep03_ux_cbdom_it ux_cbdom_it verbose_mode } cf3> -> Negated Classes = { } cf3> Initiate variable convergence... cf3> -> Immunizing against parental death cf3> -> Bundlesequence => {'service_catalogue'} cf3> cf3> ***************************************************************** cf3> BUNDLE service_catalogue cf3> ***************************************************************** cf3> cf3> cf3> + Private classes augmented: cf3> cf3> - Private classes diminished: cf3> cf3> cf3> cf3> ========================================================= cf3> services in bundle service_catalogue (1) cf3> ========================================================= cf3> cf3> !! Service type for service "ntp" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 11 cf3> !! Service type for service "nrpe" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 12 cf3> !! Service type for service "ssh" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 13 cf3> !! Service type for service "syslog" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 14 cf3> cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Skipping whole next promise (tftp), as context nim is not relevant cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Skipping whole next promise (nfs), as context nim is not relevant cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Skipping whole next promise (syslog), as context syslxlog01 is not relevant cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> cf3> + Private classes augmented: cf3> cf3> - Private classes diminished: cf3> cf3> cf3> cf3> ========================================================= cf3> services in bundle service_catalogue (2) cf3> ========================================================= cf3> cf3> !! Service type for service "ntp" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 11 cf3> !! Service type for service "nrpe" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 12 cf3> !! Service type for service "ssh" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 13 cf3> !! Service type for service "syslog" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 14 cf3> cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Skipping whole next promise (tftp), as context nim is not relevant cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Skipping whole next promise (nfs), as context nim is not relevant cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Skipping whole next promise (syslog), as context syslxlog01 is not relevant cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> cf3> + Private classes augmented: cf3> cf3> - Private classes diminished: cf3> cf3> cf3> cf3> ========================================================= cf3> services in bundle service_catalogue (3) cf3> ========================================================= cf3> cf3> !! Service type for service "ntp" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 11 cf3> !! Service type for service "nrpe" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 12 cf3> !! Service type for service "ssh" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 13 cf3> !! Service type for service "syslog" is not known cf3> Promise (version not specified) belongs to bundle 'service_catalogue' in file './services.cf' near line 14 cf3> cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Skipping whole next promise (tftp), as context nim is not relevant cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Skipping whole next promise (nfs), as context nim is not relevant cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Skipping whole next promise (syslog), as context syslxlog01 is not relevant cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . . cf3> Outcome of version (not specified): No checks were scheduled cf3> -> Checked 0 objects with 12 promises, efficiency 0.00 cf3> -> No lock purging scheduled ####################################### It's a virtual machine running on ESX 4.1 I have another machine which is RHEL 6.2 64bit physical which runs the same bundle with no problems Here's an extract from this machine's run: ################################## cf3> ========================================================= cf3> processes in bundle standard_services (1) cf3> ========================================================= cf3> cf3> Observe process table with /bin/ps -eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args cf3> cf3> ......................................................... cf3> Promise's handle: sys_procs_ntp_start cf3> Promise made by: ".*ntpd.*" cf3> cf3> Comment: Verify that the service appears in the process table cf3> ......................................................... cf3> cf3> -> Found matching pid 2106 (ntp 2106 1 2106 0.0 0.0 30212 19 1652 1 May10 00:00:10 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g) cf3> -> No signals to send for .*ntpd.* cf3> -> No restart promised for .*ntpd.* ####################################### Any hints? thanks _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine