blob: f8733029559908a026ceb4b7d93ac3c06ffe4d29 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
---
- name: install isc-dhcp-server
apt:
name: isc-dhcp-server
state: present
- name: configure interfaces
lineinfile:
path: /etc/default/isc-dhcp-server
regexp: '^INTERFACESv4='
line: "INTERFACESv4=\"{{ dhcp_server_interfaces | list | sort | join(' ') }}\""
notify: restart isc-dhcp-server
- name: configure subnets
blockinfile:
path: /etc/dhcp/dhcpd.conf
marker: '### {mark} ansible network/dhcp-server subnets ###'
block: |
{% for interface,subnet in dhcp_server_interfaces.items() %}
subnet {{ subnet.prefix | ipaddr('network') }} netmask {{ subnet.prefix | ipaddr('netmask') }} {
range {{ subnet.prefix | ipaddr(subnet.start) | ipaddr('address') }} {{ subnet.prefix | ipaddr(subnet.limit) | ipaddr('address') }};
{% if 'gateway' in subnet %}
option routers {{ subnet.gateway }};
{% endif %}
{% if 'dns' in subnet %}
option domain-name-servers {{ subnet.dns | join(', ') }};
{% endif %}
{% if 'domain' in subnet %}
option domain-name "{{ subnet.domain }}";
{% endif %}
}
{% if not loop.last %}
{% endif %}
{% endfor %}
|