summaryrefslogtreecommitdiff
path: root/data/templates/vrrp/keepalived.conf.tmpl
blob: 0595ab93fd5409177d3696f90833c3eecb23842a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Autogenerated by VyOS
# Do not edit this file, all your changes will be lost
# on next commit or reboot

global_defs {
    dynamic_interfaces
    script_user root
{% if global_parameters is defined and global_parameters is not none %}
{%     if global_parameters.startup_delay is defined %}
    vrrp_startup_delay {{ global_parameters.startup_delay }}
{%     endif %}
{%     if global_parameters.version is defined %}
    vrrp_version {{ global_parameters.version }}
{%     endif %}

{%     if global_parameters.garp is defined %}
{%         if global_parameters.garp.interval is defined %}
    vrrp_garp_interval {{ global_parameters.garp.interval }}
{%         endif %}
{%         if global_parameters.garp.master_delay is defined %}
    vrrp_garp_master_delay {{ global_parameters.garp.master_delay }}
{%         endif %}
{%         if global_parameters.garp.master_refresh is defined %}
    vrrp_garp_master_refresh {{ global_parameters.garp.master_refresh }}
{%         endif %}
{%         if global_parameters.garp.master_refresh_repeat is defined %}
    vrrp_garp_master_refresh_repeat {{ global_parameters.garp.master_refresh_repeat }}
{%         endif %}
{%         if global_parameters.garp.master_repeat is defined %}
    vrrp_garp_master_repeat {{ global_parameters.garp.master_repeat }}
{%         endif %}
{%     endif %}

{% endif %}
    notify_fifo /run/keepalived/keepalived_notify_fifo
    notify_fifo_script /usr/libexec/vyos/system/keepalived-fifo.py
}

{% if group is defined and group is not none %}
{%   for name, group_config in group.items() if group_config.disable is not defined %}
{%     if group_config.health_check is defined and group_config.health_check.script is defined and group_config.health_check.script is not none %}
vrrp_script healthcheck_{{ name }} {
    script "{{ group_config.health_check.script }}"
    interval {{ group_config.health_check.interval }}
    fall {{ group_config.health_check.failure_count }}
    rise 1
}
{%     endif %}
vrrp_instance {{ name }} {
{%     if group_config.description is defined and group_config.description is not none %}
    # {{ group_config.description }}
{%     endif %}
    state BACKUP
    interface {{ group_config.interface }}
    virtual_router_id {{ group_config.vrid }}
    priority {{ group_config.priority }}
    advert_int {{ group_config.advertise_interval }}

{%     if group_config.garp is defined %}
{%         if group_config.garp.interval is defined %}
    garp_interval {{ group_config.garp.interval }}
{%         endif %}
{%         if group_config.garp.master_delay is defined %}
    garp_master_delay {{ group_config.garp.master_delay }}
{%         endif %}
{%         if group_config.garp.master_repeat is defined %}
    garp_master_repeat {{ group_config.garp.master_repeat }}
{%         endif %}
{%         if group_config.garp.master_refresh is defined %}
    garp_master_refresh {{ group_config.garp.master_refresh }}
{%         endif %}
{%         if group_config.garp.master_refresh_repeat is defined %}
    garp_master_refresh_repeat {{ group_config.garp.master_refresh_repeat }}
{%         endif %}
{%     endif %}

{%     if group_config.track is defined and group_config.track.exclude_vrrp_interface is defined %}
    dont_track_primary
{%     endif %}
{%     if group_config.no_preempt is not defined and group_config.preempt_delay is defined and group_config.preempt_delay is not none %}
    preempt_delay {{ group_config.preempt_delay }}
{%     elif group_config.no_preempt is defined %}
    nopreempt
{%     endif %}
{%     if group_config.peer_address is defined and group_config.peer_address is not none %}
    unicast_peer {
{%         for peer_address in group_config.peer_address %}
        {{ peer_address }}
{%         endfor %}
    }
{%     endif %}
{%     if group_config.hello_source_address is defined and group_config.hello_source_address is not none %}
{%       if group_config.peer_address is defined and group_config.peer_address is not none %}
    unicast_src_ip {{ group_config.hello_source_address }}
{%       else %}
    mcast_src_ip {{ group_config.hello_source_address }}
{%       endif %}
{%     endif %}
{%     if group_config.rfc3768_compatibility is defined and group_config.peer_address is defined %}
    use_vmac {{ group_config.interface }}v{{ group_config.vrid }}
    vmac_xmit_base
{%     elif group_config.rfc3768_compatibility is defined %}
    use_vmac {{ group_config.interface }}v{{ group_config.vrid }}
{%     endif %}
{%     if group_config.authentication is defined and group_config.authentication is not none %}
    authentication {
        auth_pass "{{ group_config.authentication.password }}"
{%       if group_config.authentication.type == 'plaintext-password' %}
        auth_type PASS
{%       else %}
        auth_type {{ group_config.authentication.type | upper }}
{%       endif %}
    }
{%     endif %}
{%     if group_config.virtual_address is defined and group_config.virtual_address is not none %}
    virtual_ipaddress {
{%       for addr, addr_config in group_config.virtual_address.items() %}
        {{ addr }}{{ ' dev ' + addr_config.interface if addr_config.interface is defined }}
{%       endfor %}
    }
{%     endif %}
{%     if group_config.virtual_address_excluded is defined and group_config.virtual_address_excluded is not none %}
    virtual_ipaddress_excluded {
{%       for addr in group_config.virtual_address_excluded %}
        {{ addr }}
{%       endfor %}
    }
{%     endif %}
{%     if group_config.track is defined and group_config.track.interface is defined and group_config.track.interface is not none %}
    track_interface {
{%       for interface in group_config.track.interface %}
        {{ interface }}
{%       endfor %}
    }
{%     endif %}
{%     if group_config.health_check is defined and group_config.health_check.script is defined and group_config.health_check.script is not none %}
    track_script {
        healthcheck_{{ name }}
    }
{%     endif %}
}
{%   endfor %}
{% endif %}

{% if sync_group is defined and sync_group is not none %}
{%   for name, sync_group_config in sync_group.items() if sync_group_config.disable is not defined %}
vrrp_sync_group {{ name }} {
    group {
{%     if sync_group_config.member is defined and sync_group_config.member is not none %}
{%       for member in sync_group_config.member %}
        {{ member }}
{%       endfor %}
{%     endif %}
    }

{# Health-check scripts should be in section sync-group if member is part of the sync-group T4081 #}
{%     if vrrp is defined and vrrp.group is defined and vrrp.group is not none %}
{%       for name, group_config in group.items() if group_config.disable is not defined %}
{%         if group_config.health_check is defined and group_config.health_check.script is defined and group_config.health_check.script is not none and name in sync_group_config.member %}
    track_script {
        healthcheck_{{ name }}
    }
{%         endif %}
{%       endfor %}
{%     endif %}
{%     if conntrack_sync_group is defined and conntrack_sync_group == name %}
{%     set vyos_helper = "/usr/libexec/vyos/vyos-vrrp-conntracksync.sh" %}
    notify_master "{{ vyos_helper }} master {{ name }}"
    notify_backup "{{ vyos_helper }} backup {{ name }}"
    notify_fault "{{ vyos_helper }} fault {{ name }}"
{%     endif %}
}
{%   endfor %}
{% endif %}