Introduction

There are a number of ways to launch an event across multiple hosts. The most obvious are:

  1. Create multiple events, one for each host.
  2. Create a template, create multiple symlinks to the template.

In this example, we will show how to use a single event to do the same.

Single Event without Failover Support

The one caveat to this approach is that we cannot signal a problem using the failover_event. I.e., regardless of launch success or failure, the next event will be the same.

HOSTS=:mach1:mach2:mach3
HOST=$HOSTS[#HCRON_SELF_CHAIN]
 
as_user=
host=$HOST
command=/bin/true
notify_email=<emailaddr>
notify_message=<message>
when_month=*
when_day=*
when_hour=*
when_minute=*
when_dow=*
next_event=$HCRON_EVENT_NAME[-1]
failover_event=$HCRON_EVENT_NAME[-1]

Notes:

Multi Event with Failover Support

If we need to be able to signal on a failure via the failover_event, we can use the following setup:

HOSTS=:mach1::mach2::mach3
HOST=$HOSTS[#HCRON_SELF_CHAIN]
 
as_user=
host=$HOST
command=/bin/true
notify_email=<emailaddr>
notify_message=<message>
when_month=*
when_day=*
when_hour=*
when_minute=*
when_dow=*
next_event=multihost-null
failover_event=multihost-fail

Notes:

as_user=
host=localhost
command=/bin/true
notify_email=
notify_message=
when_year=2000
when_month=*
when_day=*
when_hour=*
when_minute=*
when_dow=*
next_event=$HCRON_EVENT_NAME[-1]
failover_event=$HCRON_EVENT_NAME[-1]

Notes:

as_user=
host=localhost
command=/bin/true
notify_email=<emailaddr>
notify_message=<message>
when_year=2000
when_month=*
when_day=*
when_hour=*
when_minute=*
when_dow=*
next_event=$HCRON_EVENT_NAME[-1]
failover_event=$HCRON_EVENT_NAME[-1]

Notes:

Conclusion

In some situations, we may not want to create separate events for each host we want to launch on. These methods provide alternatives using event chaining and indexing. In effect, given a :-separated list of hosts (e.g., HOSTS) and specially configured next_event and failover_events settings, we can select a host to launch on using #HCRON_SELF_CHAIN as an index to iterate over the host list.