Forum: CFEngine Help
Subject: variable expansion
Author: abid
Link to topic: https://cfengine.com/forum/read.php?3,27652,27652#msg-27652
Community CF3.2.3
I'm seeing an inconsistency in variable expansion. Why does this work:
#promises.cf
body common control
{
bundlesequence => { "test" };
inputs => {"cfengine_stdlib.cf"};
}
bundle agent test
{
vars:
"service" slist => {"sshd", "httpd"};
processes:
"$(service)"
comment => "Check processes running for '$(service)'",
restart_class => "restart_$(service)";
reports:
aix::
"Process $(service) not running!!!"
ifvarclass => "restart_${service}";
}
aix01 ~/.cfagent/inputs $ cf-agent -KI
-> Making a one-time restart promise for httpd
R: Process httpd not running!!!
and this not work:
# site.cf
bundle common def
{
vars:
"service" slist => {"sshd", "httpd"};
}
#promises.cf
body common control
{
bundlesequence => { "test" };
inputs => {"site.cf","cfengine_stdlib.cf"};
}
bundle agent test
{
processes:
"$(def.service)"
comment => "Check processes running for '$(def.service)'",
restart_class => "restart_$(def.service)";
reports:
aix::
"Process $(def.service) not running!!!"
ifvarclass => "restart_${def.service}";
}
aix01 ~/.cfagent/inputs $ cf-agent -KI
-> Making a one-time restart promise for $(def.service)
In the second case, $(def.service) is not being expanded.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine