diff --git a/roles/dhcpd/defaults/main.yml b/roles/dhcpd/defaults/main.yml new file mode 100644 index 0000000..1e577dd --- /dev/null +++ b/roles/dhcpd/defaults/main.yml @@ -0,0 +1,6 @@ +--- + +dhcp_interface: br-{{ site_code }} +dhcp_first: "{{ batman_ipv4 | ipaddr('512') | ipaddr('address') }}" +dhcp_last: "{{ batman_ipv4 | ipaddr('2558') | ipaddr('address') }}" +name_server: "{{ batman_ipv4 | ipaddr('address') }}" diff --git a/roles/dhcpd/handlers/main.yml b/roles/dhcpd/handlers/main.yml new file mode 100644 index 0000000..6384943 --- /dev/null +++ b/roles/dhcpd/handlers/main.yml @@ -0,0 +1,4 @@ +--- + +- name: Restart isc-dhcp-server + service: name=isc-dhcp-server state=restarted diff --git a/roles/dhcpd/tasks/main.yml b/roles/dhcpd/tasks/main.yml new file mode 100644 index 0000000..e3d6d5d --- /dev/null +++ b/roles/dhcpd/tasks/main.yml @@ -0,0 +1,11 @@ +--- + +- name: Install dhcp server + apt: name=isc-dhcp-server state=latest + +- name: Configure dhcp server + template: src=dhcpd.conf.j2 dest=/etc/dhcp/dhcpd.conf + notify: Restart isc-dhcp-server + +- name: Start the dhcp server + service: name=isc-dhcp-server state=started enabled=yes diff --git a/roles/dhcpd/templates/dhcpd.conf.j2 b/roles/dhcpd/templates/dhcpd.conf.j2 new file mode 100644 index 0000000..d8b4ca2 --- /dev/null +++ b/roles/dhcpd/templates/dhcpd.conf.j2 @@ -0,0 +1,28 @@ +# dhcpd.conf + +# option definitions common to all supported networks... +option domain-name "{{ site_domain }}"; +option domain-name-servers {{ name_server }}; + +default-lease-time 3600; +max-lease-time 14400; + +# Use this to enble / disable dynamic dns updates globally. +ddns-update-style none; + +# If this DHCP server is the official DHCP server for the local +# network, the authoritative directive should be uncommented. +authoritative; + +# Use this to send dhcp log messages to a different log file (you also +# have to hack syslog.conf to complete the redirection). +log-facility local7; + + +# Freifunk Regensburg +subnet {{ batman_ipv4 | ipaddr('network') }} netmask {{ batman_ipv4 | ipaddr('netmask') }} { + option routers {{ batman_ipv4 | ipaddr('address') }}; + pool { + range {{ dhcp_first }} {{ dhcp_last }} ; + } +} diff --git a/site.yml b/site.yml index 0318da6..60486c1 100644 --- a/site.yml +++ b/site.yml @@ -14,6 +14,7 @@ - fastd - mesh-interfaces - dns + - dhcpd - name: Setup confluence server hosts: confluence.regensburg.freifunk.net