kdnotify/doc/example.watch.yaml

56 lines
2.3 KiB
YAML

---
## This is an example configuration file for kdnotify
# Configuration related to the 'kdnotify watch' subcommand
watch:
# Arbitrary KV storage, you can add anything you like here
context:
MyInstance:
VirtualIP: 10.1.0.100/24
Device: eth0
AnotherInstance:
VirtualIP: 10.1.0.200/24
Device: eth1
# List of rules to apply to incoming VRRP messages
rules:
# Exec runs the templated command when the rule is triggered
#
# This rule runs unconditionally, for every message received,
# but we can add conditions
#
# The .Event object has three items: Instance, State and Type, which
# can be be used to filter which rules are hit by which events
- exec: /bin/logger {{.Event.Instance}} state changed to {{.Event.State}}
# This rule only runs when an event with a state of MASTER is detected
#
# Possible states are: MASTER, BACKUP and STOP
# - MASTER | The instance has been promoted to master of its' VIP(s)
# - BACKUP | The instance has been demoted, and no longer controls its' VIP(s)
# - STOP | The instance is shutting down, typically because Keepalived is exiting
- exec: /bin/logger {{.Event.Instance}} is now MASTER
state: MASTER
# Conditions can be combined, with each forming a logical AND
# Omitted conditions are ignored
#
# Possible types are:
# - INSTANCE | A vrrp_instance as defined in keepalived.conf
# - GROUP | A vrrp_group as defined in the same
- exec: /bin/logger Group {{.Event.Instance}} is stopping
state: STOP
type: GROUP
# A more complicated example, introducing the .Cxt object
#
# The .Cxt object is taken from the watch.context map listed above.
# You can add arbitrary metadata to this map and utilize it in your rules,
# as shown below
#
# A couple key points:
# - We use the index function from Go's text/template stdlib
# - We can list multiple matches for rule conditions, this applies to all
# conditions, not just 'instance'!
- exec: >-
{{ $i := index .Cxt .Event.Instance }}
/bin/logger {{.Event.Instance}} now owns {{$i.VirtualIP}}%{{$i.Device}}
instance: [MyInstance, AnotherInstance]
state: MASTER