Initial commit
This commit is contained in:
5
ansible/roles/dnsmasq/handlers/main.yml
Normal file
5
ansible/roles/dnsmasq/handlers/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: restart dnsmasq
|
||||
systemd:
|
||||
name: dnsmasq
|
||||
state: restarted
|
||||
18
ansible/roles/dnsmasq/tasks/main.yml
Normal file
18
ansible/roles/dnsmasq/tasks/main.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: Install dnsmasq
|
||||
apt:
|
||||
name: dnsmasq
|
||||
state: present
|
||||
|
||||
- name: Create dnsmasq configuration
|
||||
template:
|
||||
src: dnsmasq.conf.j2
|
||||
dest: /etc/dnsmasq.d/{{ gateway_config.lab_name }}.conf
|
||||
mode: '0644'
|
||||
notify: restart dnsmasq
|
||||
|
||||
- name: Enable and start dnsmasq
|
||||
systemd:
|
||||
name: dnsmasq
|
||||
enabled: yes
|
||||
state: started
|
||||
28
ansible/roles/dnsmasq/templates/dnsmasq.conf.j2
Normal file
28
ansible/roles/dnsmasq/templates/dnsmasq.conf.j2
Normal file
@@ -0,0 +1,28 @@
|
||||
# {{ gateway_config.lab_name }} DHCP configuration
|
||||
interface=br-{{ gateway_config.lab_name }}
|
||||
bind-interfaces
|
||||
|
||||
{% if gateway_config.dhcp_role == 'primary' %}
|
||||
# Primary DHCP server
|
||||
dhcp-range={{ gateway_config.subnet | ipaddr('10') | ipaddr('address') }},{{ gateway_config.subnet | ipaddr('127') | ipaddr('address') }},{{ gateway_config.subnet | ipaddr('netmask') }},12h
|
||||
{% elif gateway_config.dhcp_role == 'secondary' %}
|
||||
# Secondary DHCP server (split range)
|
||||
dhcp-range={{ gateway_config.subnet | ipaddr('128') | ipaddr('address') }},{{ gateway_config.subnet | ipaddr('245') | ipaddr('address') }},{{ gateway_config.subnet | ipaddr('netmask') }},12h
|
||||
{% else %}
|
||||
# Backup server (only responds if others fail)
|
||||
dhcp-range={{ gateway_config.subnet | ipaddr('10') | ipaddr('address') }},{{ gateway_config.subnet | ipaddr('245') | ipaddr('address') }},{{ gateway_config.subnet | ipaddr('netmask') }},12h
|
||||
{% endif %}
|
||||
|
||||
dhcp-option=option:router,{{ gateway_config.subnet | ipaddr('1') | ipaddr('address') }}
|
||||
dhcp-option=option:dns-server,{{ gateway_config.subnet | ipaddr('1') | ipaddr('address') }}
|
||||
|
||||
# Local DNS domain
|
||||
domain={{ gateway_config.lab_name }}.lab
|
||||
local=/{{ gateway_config.lab_name }}.lab/
|
||||
|
||||
# Lease file
|
||||
dhcp-leasefile=/var/lib/misc/dnsmasq.{{ gateway_config.lab_name }}.leases
|
||||
|
||||
# Logging
|
||||
log-dhcp
|
||||
log-queries
|
||||
Reference in New Issue
Block a user