-
Notifications
You must be signed in to change notification settings - Fork 12
Constraints
From Factotum 0.4.0 onwards, you can constrain your DAG's execution to a single host. This allows for job distribution to many servers while ensuring that the job is only run once and from one place; you can use this for example to distribute a single cron file to multiple boxes, knowing that only one server's Factotum instance will successfully invoke a given DAG.
To constrain the DAG simply append the following:
./factotum run ./echo.factotum --constraint "host,${your_hostname}"
The hostname can be:
- A wildcard
*
which means that this check always passes - The hostname of the server
- The internal IP of the server
For example running the echo.factfile
sample with constraints that all pass:
$ ./factotum run echo.factfile --constraint "host,*"
$ ./factotum run echo.factfile --constraint "host,Joshuas-iMac.local"
$ ./factotum run echo.factfile --constraint "host,192.168.1.44" # Ethernet
$ ./factotum run echo.factfile --constraint "host,192.168.1.12" # WiFi
However, if I change these to non-valid values:
$ ./factotum run echo.factfile --constraint "host,hostname"
$ Warn: the specifed host constraint "hostname" did not match, no tasks have been executed. Reason: could not find any IPv4 addresses for the supplied hostname
This means that we failed to lookup any addresses associated with the hostname given: we have nothing to compare against our local interfaces and as such we cannot obtain a match.
If I were to disconnect my WiFi network interface:
$ ./factotum run echo.factfile --constraint "host,192.168.1.12"
$ Warn: the specifed host constraint "192.168.1.12" did not match, no tasks have been executed. Reason: failed to match any of the interface addresses to the found host addresses
This means that we were able to get addresses from the local interfaces as well as from the supplied IP address, but a match could not be found within both lists.
Note: A failure to match the host constraint will result in an exit code of 0. This is because a non-matching host is considered a no-operation ("noop").