On Mon, Aug 22, 2011 at 02:41:30PM -0400, Sjoerd Oostdijck wrote:
>On 8/22/11 10:36 AM, no-re...@cfengine.com wrote:
>>  From the top-level, what I want is for "update.cf", when checking 
>> "/var/cfengine/inputs", to try one server, and if that times out, then to 
>> try another in the list.
>>
>> Now the "copy_from" compound body has a "servers" which takes a list, and 
>> the manual defines that as "the servers are tried in order until one of them 
>> succeeds".  That sounds good.  Very good.  In theory.
>>
>>
>I don't know about the examples, but having your copy body use two
>servers works just fine in my experience. Just do something like this:
>
>vars:
>          "servers"
>                 comment => "Location unknown, just set both policy hosts",
>                 slist => { "host1.foo.net","host2.foo.net" };
>
>files:
>          "/var/cfengine/inputs"
>                 copy_from           =>
>umycopy("${policyrepo}","@(servers)"),
>                 other stuff;
>
>body copy_from umycopy(from,phosts) {
>     source              => "${from}";
>     servers             => { @(phosts) };
>     compare             => "digest";
>     verify              => "true";
>     purge               => "true";
>     trustkey            => "true";
>}

You should be able to simplify the body slightly if you export the
variables in a common bundle.  I've found that 99% of the time, we copy
the files *only* from a single policy host, so writing the source host
for each promise is a waste.  Thus, I just build it into a custom,
but commonly used, copy_from body.

One difference is that we use a single hostname, but it floats between
two HA hosts (specifically which ever one is the currently active of the
two).

# Define the global variable.
bundle common g {
vars:
        'policy_server' string => 'cfengine.domain.com';
}

# Define the new copy_from update() body
body copy_from update(path) {
   any::
      servers     => { "$(g.policy_server)" };
      source      => "$(path)";
      encrypt     => "false";
      compare     => "digest";
      verify      => "false";
      copy_backup => "timestamp";
      preserve    => 'yes';
}

# Example usage
files:
     any::
        "/etc/ntp.conf"
          copy_from => update("/etc/ntp.conf.node.linux"),
          perms     => prf,
          classes   => trigger("BounceNTPd");


-- 
Jesse Becker
NHGRI Linux support (Digicon Contractor)
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to