ansible-dhcpd/tasks/main.yml
Maciej Delmanowski 9b0ad40354 Add support for ISC DHCP Relay
You can enable installation of DHCP relay instead of the server via
'dhcpd_mode' variable. By default, relays send the packets to their
network gateway, but that might not be what you really want; however
selection of correct DHCP server can be performed by specifying it in
'dhcpd_relay_servers' list.
2015-03-27 14:32:44 +01:00

39 lines
1.1 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: 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'