2024-07-13 16:08:31 +00:00
|
|
|
# TODO rewrite task and templates into something sane once the old DHCP server is retired
|
|
|
|
- set_fact:
|
|
|
|
dhcp_servers: '{{ prefixes | selectattr("custom_fields.dhcp_server") | groupby(attribute="custom_fields.dhcp_server.address") }}'
|
|
|
|
|
2023-12-18 10:22:14 +00:00
|
|
|
- name: Install keepalived
|
|
|
|
import_tasks: keepalived.yml
|
|
|
|
|
2024-07-15 09:28:33 +00:00
|
|
|
- name: Configure DHCP relays
|
2023-12-18 10:22:14 +00:00
|
|
|
template:
|
2024-07-13 16:08:31 +00:00
|
|
|
dest: '/etc/default/isc-dhcp-relay-{{ prefixes | selectattr("prefix", "==", item.0 | ipaddr("network/prefix")) | map(attribute="vrf.name") | first }}'
|
2023-12-18 10:22:14 +00:00
|
|
|
src: isc-dhcp-relay.j2
|
2024-07-13 16:08:31 +00:00
|
|
|
loop: '{{ dhcp_servers }}'
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.0 }}"
|
2024-01-30 11:36:19 +00:00
|
|
|
notify: restart keepalived
|
2023-12-18 10:22:14 +00:00
|
|
|
|
|
|
|
- name: Set up keepalived
|
|
|
|
template:
|
|
|
|
dest: /etc/keepalived/keepalived.conf
|
|
|
|
src: keepalived.conf.j2
|
|
|
|
mode: 0600
|
|
|
|
notify: restart keepalived
|
|
|
|
|
|
|
|
- name: Enable keepalived
|
|
|
|
service:
|
|
|
|
name: keepalived
|
|
|
|
enabled: yes
|
|
|
|
state: started
|