dhcp: update role to template subnet configuration correctly
This commit is contained in:
parent
ce9572631d
commit
adf511a35f
8
dhcp_server.yml
Normal file
8
dhcp_server.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: "Setup ISC-DHCP for the internal network"
|
||||||
|
hosts: dhcp_server
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- dhcp
|
||||||
|
|
@ -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:
|
||||||
|
@ -21,34 +21,36 @@ 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 }};
|
||||||
option broadcast-address {{ subnet.broadcast }};
|
option broadcast-address {{ subnet.broadcast }};
|
||||||
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 %}
|
||||||
range {{ subnet.range_start }} {{ subnet.range_end }};
|
range {{ subnet.range_start }} {{ subnet.range_end }};
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if subnet.allow_unknown is defined and subnet.allow_unknown is sameas false %}
|
{% if subnet.allow_unknown is defined and subnet.allow_unknown is sameas false %}
|
||||||
deny unknown-clients;
|
deny unknown-clients;
|
||||||
{% else %}
|
{% else %}
|
||||||
allow unknown-clients;
|
allow unknown-clients;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% for host in subnet.hosts %}
|
{% for host in subnet.hosts %}
|
||||||
host {{ host.name }} {
|
host {{ host.name }} {
|
||||||
hardware ethernet {{ host.mac }};
|
hardware ethernet {{ host.mac }};
|
||||||
{% if host.ip is defined %}
|
{% if host.ip is defined %}
|
||||||
fixed-address {{ host.ip }};
|
fixed-address {{ host.ip }};
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user