Skip to content

Commit a73191c

Browse files
authored
Implement track_process (#278)
Without this patch, a user is forced to use track_script with pgreps or kills to track process This is not a problem in itself, but is error prone. This patch fixes it by exposing in the role the track_process feature of keepalived. The initial implementation was validating some of the track_process inputs directly in the role, under the form of `param_match in ['initial', 'partial']`. Yet, this provides a different result (the incorrect data is silently not templated, and no error is thrown) as a deployer would expect. Instead, we rely on the fact that keepalived will throw a warning, and the user can check it if necessary.
1 parent 29f8985 commit a73191c

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

templates/keepalived.conf.j2

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,36 @@ vrrp_track_file {{ name }} {
5858
{% endfor %}
5959
{% endif %}
6060

61+
{% if keepalived_track_processs is defined %}
62+
{% for name, details in keepalived_track_processs.items() %}
63+
vrrp_track_process {{ name }} {
64+
process {{ details.process }} # see man 5 keepalived.conf for quotes handling
65+
weight {{ details.weight | default(1) | int }} # multiply with weight in process (default: 1, i.e. literal value from process)
66+
{% if details.param_match is defined %}
67+
param_match {{ details.param_match }}
68+
{% endif %}
69+
{% if details.quorum is defined %}
70+
quorum {{ details.quorum | int }}
71+
{% endif %}
72+
{% if details.quorum_max is defined %}
73+
quorum_max {{ details.quorum_max | int }}
74+
{% endif %}
75+
{% if details.fork_delay is defined %}
76+
fork_delay {{ details.fork_delay | int }}
77+
{% endif %}
78+
{% if details.terminate_delay is defined %}
79+
terminate_delay {{ details.terminate_delay | int }}
80+
{% endif %}
81+
{% if details.delay is defined %}
82+
delay {{ details.delay | int }}
83+
{% endif %}
84+
{% if details.full_command | default(false) | bool %}
85+
full_command
86+
{% endif %}
87+
}
88+
{% endfor %}
89+
{% endif %}
90+
6191
{% for name, sync_group in keepalived_sync_groups.items() %}
6292
vrrp_sync_group {{ name }} {
6393
group {
@@ -101,6 +131,13 @@ vrrp_sync_group {{ name }} {
101131
{% endfor %}
102132
}
103133
{% endif %}
134+
{% if sync_group.track_processs is defined %}
135+
track_process {
136+
{% for track_process in sync_group.track_processs %}
137+
{{ track_process }}
138+
{% endfor %}
139+
}
140+
{% endif %}
104141
}
105142
{% endfor %}
106143

@@ -202,6 +239,13 @@ vrrp_instance {{ name }} {
202239
{% endfor %}
203240
}
204241
{% endif %}
242+
{% if instance.track_processs is defined %}
243+
track_process {
244+
{% for track_process in instance.track_processs %}
245+
{{ track_process }}
246+
{% endfor %}
247+
}
248+
{% endif %}
205249

206250
{% if instance.notify_script is defined %}
207251
notify "{{ instance.notify_script }}"

0 commit comments

Comments
 (0)