feat: add track files
This commit is contained in:
parent
8768d2fe2f
commit
e2bee4e950
6 changed files with 42 additions and 0 deletions
|
@ -5,6 +5,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- add track files
|
||||
|
||||
### Changed
|
||||
|
||||
- keepalived_vrrp_scripts variable is now a hash
|
||||
|
|
18
README.md
18
README.md
|
@ -21,6 +21,7 @@ Install and configure Keepalived
|
|||
| keepalived_notification_mails | array | no | | the mail addresses to notify |
|
||||
| keepalived_vrrp_instances | array | no | | the vrrp instances |
|
||||
| keepalived_vrrp_scripts | hash | no | | the vrrp check scripts |
|
||||
| keepalived_track_files | hash | no | | the track files |
|
||||
|
||||
### keepalived_vrrp_instances
|
||||
|
||||
|
@ -35,6 +36,7 @@ Install and configure Keepalived
|
|||
| authentication | hash | no | | use an authentication `deprecated` |
|
||||
| virtual_ipaddresses | array | yes | | addresses add on change to MASTER, to BACKUP |
|
||||
| track_scripts | array | no | | add a tracking script to the interface |
|
||||
| track_files | array | no | | add a tracking file to the interface |
|
||||
| notify | hash | no | | notify scripts, alert as above |
|
||||
|
||||
Example:
|
||||
|
@ -79,6 +81,22 @@ check_nginx:
|
|||
interval: 10
|
||||
```
|
||||
|
||||
### keepalived_track_file
|
||||
|
||||
| Name | Type | Required | Default | Comment |
|
||||
|----------|-------|----------|---------|---------------------------------------|
|
||||
| key | str | yes | | the track file name |
|
||||
| file | str | yes | | path of the file to track |
|
||||
| weight | int | no | 1 | weigth of file |
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
master_file:
|
||||
file: /tmp/master
|
||||
weight: 3
|
||||
```
|
||||
|
||||
## How to use
|
||||
|
||||
```
|
||||
|
|
|
@ -4,3 +4,4 @@ keepalived_smtp_server: localhost
|
|||
keepalived_notification_mails: []
|
||||
keepalived_vrrp_instances: []
|
||||
keepalived_vrrp_scripts: {}
|
||||
keepalived_track_files: {}
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
fall: 3
|
||||
interval: 10
|
||||
rise: 5
|
||||
keepalived_track_files:
|
||||
master:
|
||||
file: /tmp/master
|
||||
weight: 42
|
||||
keepalived_vrrp_instances:
|
||||
- name: test
|
||||
state: master
|
||||
|
|
|
@ -13,6 +13,7 @@ def test_config_file(host):
|
|||
assert path.mode == 0o600
|
||||
assert path.contains('priority 200')
|
||||
assert path.contains('interval 10')
|
||||
assert path.contains('track_file master {')
|
||||
|
||||
def test_service(host):
|
||||
service = host.service('keepalived')
|
||||
|
|
|
@ -19,6 +19,13 @@ vrrp_script {{ vrrp_script_name }} {
|
|||
weight {{ vrrp_script.weight|default(1) }}
|
||||
}
|
||||
{% endfor %}
|
||||
{% for track_file_name, track_file in keepalived_track_files.items() %}
|
||||
|
||||
track_file {{ track_file_name }} {
|
||||
file "{{ track_file.file }}"
|
||||
weight {{ track_file.weight|default(1) }}
|
||||
}
|
||||
{% endfor %}
|
||||
{% for vrrp_instance in keepalived_vrrp_instances %}
|
||||
|
||||
vrrp_instance {{ vrrp_instance.name }} {
|
||||
|
@ -47,6 +54,13 @@ vrrp_instance {{ vrrp_instance.name }} {
|
|||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
{% if 'track_files' in vrrp_instance %}
|
||||
track_file {
|
||||
{% for script in vrrp_instance.track_files %}
|
||||
{{ script }}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
{% if 'notify' in vrrp_instance %}
|
||||
{% for state, script in vrrp_instance.notify.items() %}
|
||||
notify_{{ state }} "{{ script }}"
|
||||
|
|
Loading…
Reference in a new issue