Forum: Cfengine Help
Subject: Re: Wildcard in files stanza on copy
Author: Seva Gluschenko
Link to topic: https://cfengine.com/forum/read.php?3,17887,17954#msg-17954

Your example is still abstract enough to get the full clearance. Perhaps, if 
your node name is its hostname, you can do as simple as follows:

files:
  solaris::
        "/opt/base1/subdir/$(sys.fqhost)/subdir3/subdir4/myfiletocopy"
             comment => "Very silly way to deal with an unknown subdirectory 
name",
           copy_from => 
secure_cp("${my_actual_file_in_a_repo}","${g.cf3_server}");


If your nodename isn't its hostname, you can use configuration array:


vars:
   "node" string => "foo";
   "node" string => "bar";

files:
  solaris::
        "/opt/base1/subdir/$(node[$(sys.fqhost)])/subdir3/subdir4/myfiletocopy"
             comment => "Very silly way to deal with an unknown subdirectory 
name",
           copy_from => 
secure_cp("${my_actual_file_in_a_repo}","${g.cf3_server}");


Finally, you can use classes:


vars:
  solaris.ipv4_10_0_0::
   "node" string => "foo";

  solaris.ipv4_10_0_1::
   "node" string => "bar";

classes:
    "node_defined" expression => isvariable("node");

files:
  node_defined::
        "/opt/base1/subdir/$(node)/subdir3/subdir4/myfiletocopy"
             comment => "Very silly way to deal with an unknown subdirectory 
name",
           copy_from => 
secure_cp("${my_actual_file_in_a_repo}","${g.cf3_server}");


_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to