2024-07-13 16:08:31 +00:00
|
|
|
{% set dhcrelays = prefixes | selectattr('prefix', 'in', dhcp_servers | map('first') | ipaddr("network/prefix"))
|
|
|
|
| map(attribute="vrf.name") | map('regex_replace', '^', 'dhcrelay@') %}
|
2024-02-18 15:28:35 +00:00
|
|
|
{% set exits = [inventory_hostname, peer]|sort -%}
|
2023-12-18 10:22:14 +00:00
|
|
|
|
|
|
|
global_defs {
|
|
|
|
enable_script_security
|
|
|
|
script_user root
|
|
|
|
}
|
|
|
|
|
|
|
|
vrrp_instance dhcrelay {
|
|
|
|
virtual_router_id 50
|
|
|
|
virtual_ipaddress { 169.254.1.1/24 }
|
|
|
|
interface peerlink.4
|
|
|
|
{% for exit in exits %}
|
|
|
|
@{{ exit }} priority {{ loop.index }}
|
|
|
|
@{{ exit }} unicast_src_ip {{ "169.254.1.0/24" | ipaddr(loop.index + 1) | ipaddr('address') }}
|
|
|
|
{% endfor %}
|
|
|
|
unicast_peer {
|
|
|
|
{% for exit in exits %}
|
|
|
|
@^{{ exit }} {{ "169.254.1.0/24" | ipaddr(loop.index + 1) | ipaddr('address') }}
|
|
|
|
{% endfor %}
|
|
|
|
}
|
2024-07-13 16:08:31 +00:00
|
|
|
notify_master "systemctl start {{ dhcrelays | join(' ') }}"
|
|
|
|
notify_fault "systemctl start {{ dhcrelays | join(' ') }}"
|
|
|
|
notify_backup "systemctl stop {{ dhcrelays | join(' ') }}"
|
|
|
|
notify_stop "systemctl stop {{ dhcrelays | join(' ') }}"
|
2023-12-18 10:22:14 +00:00
|
|
|
}
|