Actually template dnsmasq

This commit is contained in:
Roxedus 2021-08-17 00:11:04 +02:00
parent a87d91d615
commit 3ab12a2991
Signed by: Roxedus
GPG Key ID: 9B4E311961C63639
4 changed files with 42 additions and 23 deletions

View File

@ -1 +1,16 @@
dmasq_local_domain: local dnsmasq_local_domain: local
dnsmasq:
aliases:
- ip: 10.0.0.1
host: "router.{{ dnsmasq_local_domain }}"
servers:
- gateway: 10.0.1.1
host: "router.iot.{{ dnsmasq_local_domain }}"
- gateway: 10.253.0.1
host: "wg.{{ dnsmasq_local_domain }}"
mask: "10.253.0.0/24"
reverse: True
- gateway: 10.0.2.1
host: "vm.{{ dnsmasq_local_domain }}"
lookup: True

View File

@ -1,3 +1,8 @@
- name: Check if dnsmasq is setup
stat:
path: "/etc/dnsmasq.d/"
register: dnsmasq_setup
- name: Set up dnsmasq hosts - name: Set up dnsmasq hosts
register: dnsmasq_hosts register: dnsmasq_hosts
become: true become: true
@ -9,6 +14,7 @@
dest: /etc/hosts.custom dest: /etc/hosts.custom
- name: Set up dnsmasq rules - name: Set up dnsmasq rules
when: dnsmasq_setup.stat.isdir is defined and dnsmasq_setup.stat.isdir
register: dnsmasq register: dnsmasq
become: true become: true
ansible.builtin.template: ansible.builtin.template:
@ -18,8 +24,13 @@
mode: 0644 mode: 0644
dest: /etc/dnsmasq.d/02-custom.conf dest: /etc/dnsmasq.d/02-custom.conf
- name: Check if PiHole is installed
stat:
path: "/usr/local/bin/pihole"
register: pihole_bin
- name: Restart PiHole systems - name: Restart PiHole systems
when: dnsmasq.changed or dnsmasq_hosts.changed when: (dnsmasq.changed or dnsmasq_hosts.changed) and pihole_bin.stat.exists
become: true become: true
ansible.builtin.command: ansible.builtin.command:
argv: argv:

View File

@ -1,17 +1,18 @@
{{ ansible_managed | comment}} {{ ansible_managed | comment }}
# http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html # http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
addn-hosts=/etc/hosts.custom addn-hosts=/etc/hosts.custom
address=/.{{ secret_wan_domain }}/10.0.0.29 {% for alias in dnsmasq.aliases %}
address=/{{ alias.host }}/{{ alias.ip }}
{% endfor %}
rev-server=10.0.0.0/24,10.0.0.1 {% for server in dnsmasq.servers %}
server=/{{ dmasq_local_domain }}/10.0.0.1 {% if server.reverse|default(False) %}
rev-server={{ server.mask }},{{ server.gateway }}
{% endif %}
{% if server.lookup|default(False) %}
server=/{{ (server.gateway.split("."))[:3] | reverse | join(".") }}.in-addr.arpa/{{ server.gateway }}
{% endif %}
server=/{{ server.host }}/{{ server.gateway }}
rev-server=10.253.0.0/24,10.253.0.1 {% endfor %}
server=/wg.{{ dmasq_local_domain }}/10.253.0.1
server=/2.0.10.in-addr.arpa/10.0.2.65
server=/vm.{{ dmasq_local_domain }}/10.0.2.65
server=/2.0.10.in-addr.arpa/10.0.2.0
server=/man.{{ dmasq_local_domain }}/10.0.2.1

View File

@ -1,9 +1 @@
{{ ansible_managed | comment}} {{ ansible_managed | comment }}
10.0.0.29 {{ secret_wan_domain }}
10.0.0.30 {{ secret_unraid_uuid }}.unraid.net
10.0.2.3 vcenter.man.{{ dmasq_local_domain }}
10.0.2.5 9010.esxi.man.{{ dmasq_local_domain }}
10.0.2.6 r710.esxi.man.{{ dmasq_local_domain }}
10.0.2.16 r710.man.{{ dmasq_local_domain }}