7dfe3855ca
- 'dhcpd_global_options' text block has been split into individual variables; - if list of nameservers is not specified, debops.dhcpd role will advertise nameservers set in '/etc/resolv.conf' file; - default set of options can be enabled or disabled using a bool variable 'dhcpd_auto_options'. The options have been moved to a separate configuration template included in main one;
54 lines
1.7 KiB
YAML
54 lines
1.7 KiB
YAML
---
|
|
|
|
- name: Configure DHCP relay in debconf
|
|
debconf:
|
|
name: 'isc-dhcp-relay'
|
|
question: 'isc-dhcp-relay/{{ item.key }}'
|
|
vtype: 'string'
|
|
value: '{{ item.value }}'
|
|
with_dict:
|
|
servers: '{{ dhcpd_relay_servers | join(" ") }}'
|
|
interfaces: '{{ dhcpd_relay_interfaces | join(" ") }}'
|
|
options: '{{ dhcpd_relay_options }}'
|
|
register: dhcpd_register_relay_debconf
|
|
when: dhcpd_mode == 'relay'
|
|
|
|
- name: Install DHCP packages
|
|
apt:
|
|
name: '{{ item }}'
|
|
state: 'present'
|
|
install_recommends: False
|
|
with_items: dhcpd_base_packages_map[dhcpd_mode]
|
|
|
|
- name: Reconfigure ISC DHCP relay
|
|
command: dpkg-reconfigure --frontend=noninteractive isc-dhcp-relay
|
|
notify: [ 'Restart isc-dhcp-relay' ]
|
|
when: dhcpd_register_relay_debconf|d() and dhcpd_register_relay_debconf.changed
|
|
|
|
- name: Get list of nameservers configured in /etc/resolv.conf
|
|
shell: grep -E '^nameserver\s' /etc/resolv.conf | awk '{print $2}' | sed -e 'N;s/\n/ /'
|
|
register: dhcpd_register_nameservers
|
|
changed_when: False
|
|
when: dhcpd_mode == 'server'
|
|
|
|
- name: Convert list of nameservers to Ansible list
|
|
set_fact:
|
|
dhcpd_runtime_nameservers: "{{ dhcpd_register_nameservers.stdout.split(' ') }}"
|
|
when: (dhcpd_register_nameservers is defined and dhcpd_register_nameservers.stdout)
|
|
|
|
- name: Configure DHCP server
|
|
template:
|
|
src: '{{ item }}.j2'
|
|
dest: '/{{ item }}'
|
|
owner: 'root'
|
|
group: 'root'
|
|
mode: '0644'
|
|
with_items: [ 'etc/default/isc-dhcp-server', 'etc/dhcp/dhcpd.conf' ]
|
|
notify: [ 'Restart isc-dhcp-server' ]
|
|
when: dhcpd_mode == 'server'
|
|
|
|
- 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'
|
|
|