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.
This commit is contained in:
parent
93cae1c116
commit
9b0ad40354
@ -1,5 +1,28 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
# What service type to configure on this host:
|
||||||
|
# 'server' - host is an ISC DHCP server, see dhcpd(8)
|
||||||
|
# 'relay' - host is an ISC DHCP relay, see dhcrelay(8)
|
||||||
|
dhcpd_mode: 'relay'
|
||||||
|
|
||||||
|
# What packages should be installed, depending on mode of operation
|
||||||
|
dhcpd_base_packages_map:
|
||||||
|
'server': [ 'isc-dhcp-server' ]
|
||||||
|
'relay': [ 'isc-dhcp-relay' ]
|
||||||
|
|
||||||
|
|
||||||
|
# ---- ISC DHCP Relay configuration ----
|
||||||
|
|
||||||
|
# List of DHCP servers which should receive the relayed packets
|
||||||
|
dhcpd_relay_servers: [ '{{ ansible_default_ipv4.gateway }}' ]
|
||||||
|
|
||||||
|
# List of network interfaces that dhcrelay should listen on
|
||||||
|
dhcpd_relay_interfaces: []
|
||||||
|
|
||||||
|
# Additional dhcrelay options
|
||||||
|
dhcpd_relay_options: '-4'
|
||||||
|
|
||||||
|
|
||||||
# ---- Global ISC DHCP Server configuration ----
|
# ---- Global ISC DHCP Server configuration ----
|
||||||
|
|
||||||
# Is this DHCP server authoritative?
|
# Is this DHCP server authoritative?
|
||||||
|
@ -5,3 +5,8 @@
|
|||||||
name: 'isc-dhcp-server'
|
name: 'isc-dhcp-server'
|
||||||
state: 'restarted'
|
state: 'restarted'
|
||||||
|
|
||||||
|
- name: Restart isc-dhcp-relay
|
||||||
|
service:
|
||||||
|
name: 'isc-dhcp-relay'
|
||||||
|
state: 'restarted'
|
||||||
|
|
||||||
|
@ -1,11 +1,29 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- 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
|
- name: Install DHCP packages
|
||||||
apt:
|
apt:
|
||||||
name: '{{ item }}'
|
name: '{{ item }}'
|
||||||
state: 'present'
|
state: 'present'
|
||||||
install_recommends: False
|
install_recommends: False
|
||||||
with_items: [ 'isc-dhcp-server' ]
|
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
|
- name: Configure DHCP server
|
||||||
template:
|
template:
|
||||||
@ -16,4 +34,5 @@
|
|||||||
mode: '0644'
|
mode: '0644'
|
||||||
with_items: [ 'etc/default/isc-dhcp-server', 'etc/dhcp/dhcpd.conf' ]
|
with_items: [ 'etc/default/isc-dhcp-server', 'etc/dhcp/dhcpd.conf' ]
|
||||||
notify: [ 'Restart isc-dhcp-server' ]
|
notify: [ 'Restart isc-dhcp-server' ]
|
||||||
|
when: dhcpd_mode == 'server'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user