Forum: CFEngine Help
Subject: odd vars definition
Author: roadtest
Link to topic: https://cfengine.com/forum/read.php?3,25029,25029#msg-25029

Hi,
I defined a method on a client, which can be activated by remote cf-runagent  
on cfengine server as "cf-runagent -DBinUpdate -H ". Then it will kill 
application process, pull new binary, then start application process. Here is 
the bundle:
================================================
$cat -n vsrv.cf
     1  #####################################################
     2  #                                                   #
     3  # configuration file for VSRV server        #
     4  #                                                   #
     5  #####################################################
     6  ##
     7  ##
     8  bundle agent OnHost
     9  {
    10  #vars:
    11  #       "policyhost" string => "172.16.13.123";
    12
    13
    14  reports:
    15       cfengine::
    16              "$(sys.fqhost) is ready to update VSRV configuration";
    17
    18  methods:
    19       BinUpdate::
    20              "vsrv" usebundle => UpdateWorkFlow;
    21
    22  }
    23
    24  bundle agent UpdateWorkFlow
    25  {
    26  vars:
    27          "policyhost" string => "172.16.13.123";
    28
    29  reports:
    30          windows::
    31                  "I am inside UpdateWorkFlow bundle";
    32
    33  processes:
    34          "sleep"
    35                  signals => { "term","kill" },
    36                  classes => if_repaired("PullFiles");
    37
    38  #reports:
    39  #       PullFiles::
    40  #               "I am inside PullFiles section";
    41
    42  PullFiles::
    43  files:
    44          "/data/vsrv/."
    45                  comment => "Update Application Binary from CFEngine Repo
sitory Server",
    46                  create  => "true",
    47                  depth_search => u_recurse("inf"),
    48                  perms => u_workdir_perms("0755"),
    49                  copy_from => remote_cp("/data/vsrv","$(policyhost)");
    50
    51  }
    52

================================================

If I define "policyhost" on  line27, everything is working as expected. If I 
define "policyhost" on line  11, it will show following errors:
=================================================
$cf-agent -DBinUpdate -v -K
...
cf3-->  -> Copy file /data/vsrv/. from /data/vsrv check
cf3--> Unable to lookup hostname ($(policyhost)) or cfengine service: hostname n
or servname provided, or not known
cf3--> Unable to lookup hostname ($(policyhost)) or cfengine service: hostname n
or servname provided, or not known
cf3--> No existing connection to $(policyhost) is established...
cf3--> Set cfengine port number to 5308 = 5308
cf3--> Set connection timeout to 10
cf3-->  !! Unable to find host or service: ($(policyhost)/5308) hostname nor ser
vname provided, or not known
cf3-->  !! No server is responding on this port
cf3--> Unable to establish connection with $(policyhost)
cf3--> Unable to lookup hostname ($(policyhost)) or cfengine service: hostname n
or servname provided, or not known
cf3-->  -> No suitable server responded to hail
cf3--> Promise (version not specified) belongs to bundle 'UpdateWorkFlow' in fil
e '/var/cfengine/masterfiles/sites/vsrv.cf' near line 45
cf3--> Comment: Update Application Binary from CFEngine Repository Server
...
=================================================

Per my understanding, promise types are executed in order - 
vars,classes,methods,processes,commands,reports. Why I have to define variable 
in the same bundle?

I also tried to define "policyhost" in common bundle with the same error. Here 
is my promises.cf
==================================================
$ less promises.cf
#####################################################
#                                                   #
# promises.cf - Main Cfengine 3 configuration file  #
#                                                   #
#####################################################

body common control {

    any::

        bundlesequence => { @(g.bundlesequence) };

    any::

        inputs => {
            "update.cf",
            "cfengine_stdlib.cf",
            "classes.cf",
            "/var/cfengine/masterfiles/cf-execd.cf",
            "/var/cfengine/masterfiles/cf-serverd.cf",
            "cf-report.cf",
            "cleanup.cf",
            "$(g.sitesfiles)/$(global.HostFunction).cf"
        };

    output_prefix => "cf3--";
}

# global vars
bundle common g {

vars:

    "workdir"           string => "/var/cfengine";
    "masterfiles"       string => "$(workdir)/masterfiles";
    "binaryfiles"       string => "$(workdir)/bin";
    "inputfiles"        string => "$(workdir)/inputs";
    "sitesfiles"        string => "$(workdir)/masterfiles/sites";
    "policyhost"        string => "172.16.13.123";
    "bundlesequence"    slist  => { "update", "executor", "server","cleanup", "O
nHost" };
##    "bundlesequence"    slist  => { "update", "executor", "server","cleanup" }
;
}

body runagent control {
    hosts => { "127.0.0.1", "10.127.247.0/24", "10.127.248.0/24" };
}
==================================================

What did I miss? Thanks in advance!

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to