Hello,
I am trying to setup multiple cfengine environments similar to the one in Diego Zamboni's book. In the example in the book, the class 'environment_development' is set based on the ip addresses. In my case, it is supposed to be set based on a module.
Prior to calling the environments bundle, I call the 'hostinfo' bundle (~/masterfiles/
hostinfo.cf) which calls the 'hostinfo' module (~/modules/hostinfo). This module reads a file on the server and sets one of the classes: (tierLab|tierSys|tierUat, etc.) based on the information in the file.
In the environments bundle, if the class 'tierSys' is set, then, it is supposed to set the 'env' variable to 'dev' and in the
promises.cf file, the path of the inputs file is supposed to be: dev/
env_promises.cf
When I run 'cf-agent -KI ~/masterfiles/
promises.cf', I get the following error.
2015-08-27T09:29:45-0500 error: Unresolved variable '$(environments.env)/
env_promises.cf' in input list, cannot parse
But looking further down in the output, I can see that the 'hostinfo' module is executing and that the 'env' variable is set to 'dev'. So, I don't understand why I am getting the error message. Can someone help. Thanks
2015-08-27T10:26:50-0500 info: /default/hostinfo/commands/'/var/cfengine/modules/hostinfo'[0]: Executing 'no timeout' ... '/var/cfengine/modules/hostinfo'
2015-08-27T10:26:50-0500 info: /default/hostinfo/commands/'/var/cfengine/modules/hostinfo'[0]: Completed execution of '/var/cfengine/modules/hostinfo'
R: bundle: environments; env is: dev
The following is the code:
-----------
body common control
{
bundlesequence => {
<snip>
service_catalogue,
@(cfengine_enterprise_hub_ha.management_bundles),
hostinfo, # ntrs hostinfo module
environments, # ntrs cfengine environments
<snip>
inputs => {
<snip>
# List of services here
# ntrs hostinfo at: ~/masterfiles/
<snip>
}
bundle hostinfo
--------------
bundle agent hostinfo
{
commands:
# Renaming the cf2 module filename: 'module:hostinfo' to 'hostinfo'
#"$(sys.workdir)/modules/hostinfo" # /var/cfengine/modules/hostinfo
"/var/cfengine/modules/hostinfo" # /var/cfengine/modules/hostinfo
module => "true";
}
module: hostinfo (~/modules/hostinfo):
--------------------------
<snip>
echo "+tierSys"
I tried running environments bundle as 'bundle common environments' as well. But, no luck. Here, it is 'bundle agent'
But, if I change the class 'tierSys::' to 'linux::', the 'env' variable is set.
----------------------
bundle agent environments
{
vars:
tierSys::
"env" string => "dev";
reports:
any::
"bundle: $(this.bundle); env is: $(environments.env) ";
}