WIP: DHCP server #95

Draft
jeltz wants to merge 6 commits from dhcp into master
6 changed files with 76 additions and 0 deletions
Showing only changes of commit 6bb2bbb54f - Show all commits

View file

@ -3,6 +3,7 @@ ask_vault_pass = True
roles_path = ./roles roles_path = ./roles
retry_files_enabled = False retry_files_enabled = False
inventory = ./hosts inventory = ./hosts
filter_plugins = ./filter_plugins
ansible_managed = Ansible managed, modified on %Y-%m-%d %H:%M:%S ansible_managed = Ansible managed, modified on %Y-%m-%d %H:%M:%S
nocows = 1 nocows = 1
forks = 15 forks = 15

View file

@ -0,0 +1,8 @@
---
dhcpd_interfaces: []
dhcpd__default_lease_time: 600
dhcpd__max_lease_time: 7200
dhcpd__dns_servers: []
dhcpd__domain_search: []
dhcpd__subnets: []
...

View file

@ -0,0 +1,6 @@
---
- name: Restart isc-dhcp-server
systemd:
name: isc-dhcp-server.service
state: restarted
...

View file

@ -0,0 +1,29 @@
---
- name: Install isc-dhcp-server
apt:
name: isc-dhcp-server
- name: Configure isc-dhcp-server
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: u=rw,g=r,o=
owner: root
group: root
loop:
- src: dhcpd.conf.j2
dest: /etc/dhcp/dhcpd.conf
- src: default.j2
dest: /etc/default/isc-dhcp-server
notify:
- Restart isc-dhcp-server
#- src: dhcpd6.conf.j2
# dest: /etc/dhcp/dhcpd6.conf
- name: Enable and start isc-dhcp-server
systemd:
name: isc-dhcp-server.service
state: started
enabled: true
...

View file

@ -0,0 +1,4 @@
{{ ansible_managed | comment }}
INTERFACESv4="{{ dhcpd__interfaces | join(' ') }}"
INTERFACESv6=""

View file

@ -0,0 +1,28 @@
{{ ansible_managed | comment }}
default-lease-time {{ dhcpd__default_lease_time }};
max-lease-time {{ dhcpd__max_lease_time }};
ddns-update-style none;
authoritative;
{% if dhcpd__dns_servers | default([]) %}
option domain-name-servers {{ dhcpd__dns_servers | join(", ") }};
{% endif %}
{% if dhcpd__domain_search | default([]) %}
option domain-search {{ dhcpd__domain_search | map("enquote") | join(", ") }};
{% endif %}
{% for subnet in dhcpd__subnets %}
subnet {{ subnet.network
| ansible.utils.ipaddr("network") }}
netmask {{ subnet.network
| ansible.utils.ipaddr("netmask") }} {
range {{ subnet.start }} {{ subnet.end }};
{% if subnet.routers | default([]) %}
option routers {{ subnet.routers | join(", ") }};
{% endif %}
}
{% endfor %}