Forum: CFEngine Help Subject: can't find the defined variable Author: roadtest Link to topic: https://cfengine.com/forum/read.php?3,25022,25022#msg-25022
Hello, I am trying to define CFEngine policy so that I can issue cf-runagent from policy server to activate UpdateClass on remote clients. Inside the UpdateClass, it will first shutdown application process, then pull binary from policy server, then start the process. Here is what I did. $cat vsrv.cf bundle agent OnHost { vars: "u_policyhost" string => "172.16.13.123"; reports: cfengine:: "$(sys.fqhost) is ready to update VSRV configuration"; methods: BinUpdate:: "vsrv" usebundle => UpdateWorkFlow; } bundle agent UpdateWorkFlow { reports: windows:: "I am inside UpdateWorkFlow bundle"; processes: "sleep" signals => { "term","kill" }, classes => if_repaired("PullFiles"); #reports: # PullFiles:: # "I am inside PullFiles section"; PullFiles:: files: "/data/vsrv/." comment => "Update Application Binary from CFEngine Repository Server", create => "true", depth_search => u_recurse("inf"), perms => u_workdir_perms("0755"), copy_from => remote_cp("/data/vsrv","$(u_policyhost)"); # line with problem,even I change it to "policyhost", still report hostname is not defined } In my promises.cf $cat promises.cf 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)/vsrv.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", "OnHost" }; ## "bundlesequence" slist => { "update", "executor", "server","cleanup" }; } body runagent control { hosts => { "127.0.0.1", "10.127.247.0/24", "10.127.248.0/24" }; } cf-promise doesn't report error. When I run cf-agent, it doesn't copy files from policy server and error in debug message is as following: #cf-agent -DBinUpdate -v ...... cf3--> Copy file /data/vsrv/. from /data/vsrv check cf3--> Unable to lookup hostname ($(policyhost)) or cfengine service: hostname nor servname provided, or not known cf3--> Unable to lookup hostname ($(policyhost)) or cfengine service: hostname nor servname provided, or not known cf3--> No existing connection to $(policyhost) is established... Why it ignores the local defined variable? Thanks, _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine