Copy failover example

From Cfwiki

Jump to: navigation, search

A question about failover attribute for copy worked. There seemed to be confusion about being able to supply mutiple failovers. You can indeed supply multiple failover by chaining the classes in order. Each copy statement can have a failover class. If the first server fails, then it attempts the next by defining an additional failver class. Finally I give up and send out an alert. Notice the use of AddInstallable.

 control:

    actionsequence = ( copy )

    AddInstallable = ( failed1 failed2 broken )

 copy:

    any::
        /var/tmp/test
            dest=/var/tmp/test
            server=192.168.1.2
            failover=failed1

    failed1::
        /var/tmp/test
            dest=/var/tmp/test
            server=192.168.1.3
            failover=failed2

    failed2::
        /var/tmp/test
            dest=/var/tmp/test
            server=192.168.1.4
            failover=broken

 alerts:

    broken::
        "Failed to copy configs"

This is the example output:

pearcec@wideload:/var/tmp$ cfagent -f ./copy-test.cf  -I
cfengine:: Couldn't open a socket
cfengine:: Unable to establish connection with 192.168.1.2 (failover)
cfengine:: Couldn't open a socket
cfengine:: Unable to establish connection with 192.168.1.3 (failover)
cfengine:: Couldn't open a socket
cfengine:: Unable to establish connection with 192.168.1.4 (failover)
cfengine:: Failed to copy configs
Personal tools