Forum: CFEngine Help
Subject: Re: variable expansion in commands / args
Author: nickanderson
Link to topic: https://cfengine.com/forum/read.php?3,26122,26123#msg-26123
Are you sure you don't have any syntax errors?
var:
classa::
munki_manifestname string => "mani_client";
var should be vars
and munki_manifestname should be quoted.
Does your command get executed before munki_manifestname is set?
For example if your depending on a classes type promise to set classa or classb
then munki_manifestname won't get set until the second pass. Your command
promise would have executed on the first pass and $(munki_manifestname) would
not be a defined variable and could not be dereferenced.
You can set a class when your munki_manifestname variable is set and restrict
your commands promise to that context.
This is not tested but hopefully correct enough.
bundle agent main {
vars:
classa:
"munki_manifestname" string => "mani_client";
classb:
"munki_manifestname" string => "mani_admin";
classes:
"munki_manifestname_defined" expression => isvariable("munki_manifestname");
commands:
execute_write_new_manifest::
"/bin/echo"
args => "$(munki_manifestname)",
ifvarclass => "munki_manifestname_defined";
}
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine