Forum: Cfengine Help
Subject: Populating slist from an execresult
Author: nbianchi
Link to topic: https://cfengine.com/forum/read.php?3,18222,18222#msg-18222
We grabbed the HPC configuration example from the solutions guide and we're
using it as a base for assuring that sevices that are chkconfig'd "on" are
actually running.
The problem is in the population of the list from the execresult below.
I can run the command in a shell without issue, but it is not getting to the
variable.
######
vars:
"services" slist => execresult("/bin/ls /etc/rc.d/rc3.d/S*|/usr/bin/sed
's/\/etc\/rc.d\/rc3.d\/S[0-9][0-9]//'", "useshell");
######
When running cf-promises -f cf-process.cf.new -v we get this output.
What does this mean?
######
Validation: rhs is a scalar, but lhs (slist) is not a scalar type
######
We are then iterating through this list to assure that these services are
really running.
##########
methods:
# perform the actual check and restart on services included in the list above
"any" usebundle => enable_service("$(services)");
}
###############################################################################
bundle agent enable_service(name)
{
vars:
"status" string => execresult("/sbin/chkconfig $(name)", "useshell");
classes:
"on" expression => regcmp(".*on","$(status)");
"off" expression => regcmp(".*off","$(status)");
on::
"running" expression => returnszero("/sbin/service $(name)
status","noshell");
commands:
on.!running::
"/sbin/service $(name) restart",
comment => "Restart $(name) service";
reports:
on.!running::
"Restarted $(name) service.";
off::
"$(name) has been already disabled. Don't need to perform any actions.";
}
Thoughts, comments, suggestions?
Thanks in advance,
Nicola
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine