ansible-dhcpd/tasks/main.yml

47 lines
1.4 KiB
YAML
Raw Normal View History

---
- include: dist_vars.yml
- include: install.yml
- name: Get list of nameservers configured in /etc/resolv.conf
shell: grep -E '^nameserver\s' /etc/resolv.conf | awk '{print $2}'
register: dhcpd_register_nameservers
changed_when: False
when: dhcpd_mode == 'server'
2017-06-01 07:38:43 +00:00
check_mode: False
- name: Convert list of nameservers to Ansible list
set_fact:
dhcpd_runtime_nameservers: "{{ dhcpd_register_nameservers.stdout_lines }}"
when: (dhcpd_register_nameservers is defined and dhcpd_register_nameservers.stdout)
- name: Configure DHCP server
2015-03-27 09:50:21 +00:00
template:
2021-10-24 18:54:44 +00:00
src: "etc/dhcp/dhcpd.conf.j2"
dest: "/{{ item }}"
owner: "root"
group: "root"
mode: "0644"
with_items: "{{ dhcpd_templates }}"
2021-10-24 18:54:44 +00:00
notify: ["Restart dhcp server"]
register: dhcpd_register_config
when: dhcpd_mode == 'server'
- name: Make sure that included files exist
file:
2021-10-24 18:54:44 +00:00
path: "{{ item }}"
state: "touch"
owner: "root"
group: "root"
mode: "0644"
with_items: "{{ dhcpd_includes }}"
notify: ["Restart dhcp server"]
when: ((item is defined and item) and dhcpd_mode == 'server' and
2021-10-24 18:54:44 +00:00
(dhcpd_register_config is defined and dhcpd_register_config.changed))
- name: Make sure that IPv6 lease file exists
command: touch /var/lib/dhcp/dhcpd6.leases creates=/var/lib/dhcp/dhcpd6.leases
when: dhcpd_ipversion == '6'
- include: dhcp-probe.yml
when: dhcpd_probe|d() and dhcpd_probe