network/roles/exit/tasks/dhcp.yml

29 lines
868 B
YAML
Raw Normal View History

# 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
- name: Configure DHCP relays
2023-12-18 10:22:14 +00:00
template:
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
loop: '{{ dhcp_servers }}'
loop_control:
label: "{{ item.0 }}"
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