dhcp: update role to template subnet configuration correctly

This commit is contained in:
Johanna Dorothea Reichmann 2020-06-07 20:13:46 +02:00
parent ce9572631d
commit adf511a35f
Signed by: transcaffeine
GPG Key ID: 03624C433676E465
3 changed files with 23 additions and 12 deletions

8
dhcp_server.yml Normal file
View File

@ -0,0 +1,8 @@
---
- name: "Setup ISC-DHCP for the internal network"
hosts: dhcp_server
become: true
roles:
- dhcp

View File

@ -13,6 +13,7 @@
group: root group: root
mode: 0644 mode: 0644
setype: dhcp_etc_t setype: dhcp_etc_t
validate: dhcpd -t
- name: Restart & enable DHCP-server - name: Restart & enable DHCP-server
systemd: systemd:

View File

@ -21,6 +21,7 @@ option domain-name-servers {{ dhcp_common_name_servers|join(', ') }};
log-facility local7; log-facility local7;
# Subnet definitions # Subnet definitions
{% for subnet in dhcp_subnets %} {% for subnet in dhcp_subnets %}
subnet {{ subnet.net }} netmask {{ subnet.netmask }} { subnet {{ subnet.net }} netmask {{ subnet.netmask }} {
option routers {{ subnet.routers }}; option routers {{ subnet.routers }};
@ -28,7 +29,7 @@ subnet {{ subnet.net }} netmask {{ subnet.netmask }} {
option domain-name "{{ subnet.domain_name }}"; option domain-name "{{ subnet.domain_name }}";
option domain-name-servers {{ subnet.domain_name_servers|join(', ') }}; option domain-name-servers {{ subnet.domain_name_servers|join(', ') }};
{% if subnet.domain_search is defined and subnet.domain_search|length > 0 %} {% if subnet.domain_search is defined and subnet.domain_search|length > 0 %}
option domain-search {{ subnet.domain_search | map('regex_replace', '(.*)', '\"\\1\"') | join(', ') }}; option domain-search {{ subnet.domain_search | map('regex_replace', '^(.*)$', '\"\\1\"') | join(', ') }};
{% endif %} {% endif %}
{% if subnet.range_start is defined and subnet.range_end is defined %} {% if subnet.range_start is defined and subnet.range_end is defined %}
@ -50,5 +51,6 @@ subnet {{ subnet.net }} netmask {{ subnet.netmask }} {
} }
{% endfor %} {% endfor %}
} }
{% endfor %} {% endfor %}