Forum: CFEngine Help Subject: regcmp() not working correctly? Author: daveseff Link to topic: https://cfengine.com/forum/read.php?3,27556,27556#msg-27556
I have a bundle for disabling services: bundle agent disable_services(name) { vars: "status" string => execresult("/sbin/chkconfig --list $(name)", "useshell"); classes: "service_$(name)_exists" or => { fileexists("/etc/init.d/$(name)"), fileexists("/etc/xinetd.d/$(name)") }; "service_on" expression => regcmp(".*on.*","$(status)"); commands: service_on:: "/sbin/chkconfig $(name) off", comment => "disable $(name) service", ifvarclass => "service_$(name)_exists"; reports: service_on:: "disable $(name) service.", ifvarclass => "service_$(name)_exists"; } My issue is that even a service such as haldaemon os off, cfagent wants to execute /sbin/chkconfig haldaemon off everytime regardless of expression => regcmp(".*on.*","$(status)"); # cf-agent -IK -> Executing '/sbin/chkconfig haldaemon off' ...(timeout=-678,owner=-1,group=-1) -> Completed execution of /sbin/chkconfig haldaemon off R: disable haldaemon service. Happens everytime even if: # /sbin/chkconfig --list haldaemon haldaemon 0:off 1:off 2:off 3:off 4:off 5:off 6:off _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine