In the example below it seems like the bundle is getting run twice.
The first time it does what we want.
But then it's trying to set the $(status) variable a second time and complains
about it. Adding ", policy => overridable" makes the warning go away, but we
still don't want the definition happening twice.
Is this a bug, or are we doing something wrong?
We're using community version 3.0.5.
bash-3.00# cf-agent -f ./cf3.test -KI
-> Executing '/sbin/chkconfig rlogin off' ...(timeout=-678,owner=-1,group=-1)
-> Completed execution of /sbin/chkconfig rlogin off
R: disable rlogin service.
!! Duplicate selection of value for variable "status" in scope disable_xinetd
Rule from ./cf3.test at/before line 32
R: rlogin has been already disabled. Don't need to perform the action.
bash-3.00# cat cf3.test
body common control
{
bundlesequence => { main };
}
bundle agent main
{
methods:
"any" usebundle => disable_xinetd("rlogin");
}
bundle agent disable_xinetd(name)
{
vars:
"status" string => execresult("/sbin/chkconfig --list | /usr/bin/grep
$(name)", "useshell");
classes:
"on" expression => regcmp(".*on","$(status)");
"off" expression => regcmp(".*off","$(status)");
commands:
on::
"/sbin/chkconfig $(name) off",
comment => "disable $(name) service";
reports:
on::
"disable $(name) service.";
off::
"$(name) has been already disabled. Don't need to perform the action.";
}
--
Tod Oace, Intel Corporation <[email protected]>
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine