Compare commits
No commits in common. "d7275597a03a5efa5773678fc4156b373799dfae" and "b9baf12530123ec33a152b9d0208a6d46f84ecdf" have entirely different histories.
d7275597a0
...
b9baf12530
18
README.md
18
README.md
@ -4,19 +4,19 @@ Ce rôle permet d'installer et configurer dnsmasq.
|
|||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
### dnsmasq_domain
|
### dnsmasq_conf_domain
|
||||||
|
|
||||||
Nom de domain utilisé pour qualifier les noms courts.
|
Nom de domain utilisé pour qualifier les noms courts.
|
||||||
|
|
||||||
*<span style="text-decoration: underline">Valeur par défaut:</span> aucune*
|
*<span style="text-decoration: underline">Valeur par défaut:</span> aucune*
|
||||||
|
|
||||||
### dnsmasq_servers
|
### dnsmasq_conf_servers
|
||||||
|
|
||||||
Liste d'adresses IP auxquelles les requêtes DNS sont transmises si dnsmasq ne porte pas le domaine.
|
Liste d'adresses IP auxquelles les requêtes DNS sont transmises si dnsmasq ne porte pas le domaine.
|
||||||
|
|
||||||
*<span style="text-decoration: underline">Valeur par défaut:</span> aucune*
|
*<span style="text-decoration: underline">Valeur par défaut:</span> aucune*
|
||||||
|
|
||||||
### dnsmasq_hosts
|
### dnsmasq_servers
|
||||||
|
|
||||||
Liste d'IP ou de noms d'hôtes servant de serveur DNS.
|
Liste d'IP ou de noms d'hôtes servant de serveur DNS.
|
||||||
|
|
||||||
@ -46,12 +46,6 @@ Nom d'hôte du client.
|
|||||||
|
|
||||||
*<span style="text-decoration: underline">Valeur par défaut:</span> `{{ inventory_hostname }} {{ inventory_hostname_short }}`*
|
*<span style="text-decoration: underline">Valeur par défaut:</span> `{{ inventory_hostname }} {{ inventory_hostname_short }}`*
|
||||||
|
|
||||||
### dnsmasq_specifics
|
|
||||||
|
|
||||||
Liste de dictionnaires contenant le nom d'hôte, les alias et la liste d'IP associées.
|
|
||||||
|
|
||||||
*<span style="text-decoration: underline">Valeur par défaut:</span> aucune*
|
|
||||||
|
|
||||||
## Exemple d'utilisation
|
## Exemple d'utilisation
|
||||||
|
|
||||||
### inventory.yml
|
### inventory.yml
|
||||||
@ -75,7 +69,7 @@ all:
|
|||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
|
|
||||||
dnsmasq_hosts: "{{ groups['dnsservers'] }}"
|
dnsmasq_servers: "{{ groups['dnsservers'] }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -84,8 +78,8 @@ dnsmasq_hosts: "{{ groups['dnsservers'] }}"
|
|||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
|
|
||||||
dnsmasq_domain: ykn.local
|
dnsmasq_conf_domain: ykn.local
|
||||||
dnsmasq_servers:
|
dnsmasq_conf_servers:
|
||||||
- 127.0.0.1#53000
|
- 127.0.0.1#53000
|
||||||
- ::1#53000
|
- ::1#53000
|
||||||
```
|
```
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
---
|
---
|
||||||
# defaults file for dnsmasq
|
# defaults file for dnsmasq
|
||||||
|
|
||||||
dnsmasq_domain: ""
|
dnsmasq_conf_domain: ""
|
||||||
dnsmasq_servers: []
|
dnsmasq_conf_servers: []
|
||||||
dnsmasq_rev_servers: []
|
|
||||||
dnsmasq_bogus_priv_enabled: true
|
|
||||||
|
|
||||||
dnsmasq_hosts: []
|
dnsmasq_servers: []
|
||||||
|
|
||||||
dnsmasq_host_ips: []
|
dnsmasq_host_ips: []
|
||||||
dnsmasq_host_aliases: []
|
dnsmasq_host_aliases: []
|
||||||
|
|
||||||
dnsmasq_client_filename: "{{ inventory_hostname }}"
|
dnsmasq_client_filename: "{{ inventory_hostname }}"
|
||||||
dnsmasq_client_hostname: "{{ inventory_hostname }} {{ inventory_hostname_short }}"
|
dnsmasq_client_hostname: "{{ inventory_hostname }} {{ inventory_hostname_short }}"
|
||||||
|
|
||||||
dnsmasq_specifics: []
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
state: reloaded
|
state: reloaded
|
||||||
name: dnsmasq.service
|
name: dnsmasq.service
|
||||||
loop: "{{ dnsmasq_hosts }}"
|
loop: "{{ dnsmasq_servers }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: dnsserver
|
loop_var: dnsserver
|
||||||
delegate_to: "{{ dnsserver }}"
|
delegate_to: "{{ dnsserver }}"
|
||||||
|
@ -9,9 +9,10 @@
|
|||||||
src: "{{ role_path }}/templates/host.conf.j2"
|
src: "{{ role_path }}/templates/host.conf.j2"
|
||||||
dest: /srv/dnsmasq/{{ dnsmasq_client_filename }}.conf
|
dest: /srv/dnsmasq/{{ dnsmasq_client_filename }}.conf
|
||||||
when:
|
when:
|
||||||
- dnsmasq_hosts | length > 0
|
- dnsmasq_servers | length > 0
|
||||||
- dnsmasq_host_ipv4 not in dnsmasq_hosts
|
- dnsmasq_host_ipv4 not in dnsmasq_servers
|
||||||
loop: "{{ dnsmasq_hosts }}"
|
tags: creation
|
||||||
|
loop: "{{ dnsmasq_servers }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: dnsserver
|
loop_var: dnsserver
|
||||||
delegate_to: "{{ dnsserver }}"
|
delegate_to: "{{ dnsserver }}"
|
||||||
@ -23,10 +24,10 @@
|
|||||||
path: /srv/dnsmasq/{{ dnsmasq_client_filename }}.conf
|
path: /srv/dnsmasq/{{ dnsmasq_client_filename }}.conf
|
||||||
state: absent
|
state: absent
|
||||||
when:
|
when:
|
||||||
- dnsmasq_hosts | length > 0
|
- dnsmasq_servers | length > 0
|
||||||
- dnsmasq_host_ipv4 not in dnsmasq_hosts
|
- dnsmasq_host_ipv4 not in dnsmasq_servers
|
||||||
tags: [destruction, never]
|
tags: [destruction, never]
|
||||||
loop: "{{ dnsmasq_hosts }}"
|
loop: "{{ dnsmasq_servers }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: dnsserver
|
loop_var: dnsserver
|
||||||
delegate_to: "{{ dnsserver }}"
|
delegate_to: "{{ dnsserver }}"
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
---
|
---
|
||||||
# tasks file for security
|
# tasks file for security
|
||||||
|
|
||||||
- name: Supprimer l'ancien fichier de configuration
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /etc/dnsmasq.d/cache.conf
|
|
||||||
state: absent
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Configurer dnsmasq
|
- name: Configurer dnsmasq
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: dnsmasq.conf.j2
|
src: dnsmasq.conf.j2
|
||||||
dest: /etc/dnsmasq.d/dns.conf
|
dest: /etc/dnsmasq.d/cache.conf
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: u=rw,g=r,o=r
|
mode: u=rw,g=r,o=r
|
||||||
@ -19,26 +13,10 @@
|
|||||||
|
|
||||||
- name: Déployer la configuration de l'instance
|
- name: Déployer la configuration de l'instance
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
owner: dnsmasq
|
||||||
|
group: root
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
src: host.conf.j2
|
src: host.conf.j2
|
||||||
dest: /srv/dnsmasq/{{ inventory_hostname }}.conf
|
dest: /srv/dnsmasq/{{ inventory_hostname }}.conf
|
||||||
owner: dnsmasq
|
|
||||||
group: root
|
|
||||||
mode: u=rw,g=r,o=r
|
|
||||||
become: true
|
become: true
|
||||||
notify: Recharger dnsmasq.service
|
notify: Recharger dnsmasq.service
|
||||||
|
|
||||||
- name: Déployer les configurations specifiques
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: specific.conf.j2
|
|
||||||
dest: "{{ filename }}"
|
|
||||||
owner: dnsmasq
|
|
||||||
group: root
|
|
||||||
mode: u=rw,g=r,o=r
|
|
||||||
when: dnsmasq_specifics | length > 0
|
|
||||||
become: true
|
|
||||||
notify: Recharger dnsmasq.service
|
|
||||||
loop: "{{ dnsmasq_specifics }}"
|
|
||||||
loop_control:
|
|
||||||
label: "{{ filename }}"
|
|
||||||
vars:
|
|
||||||
filename: /srv/dnsmasq/{{ item.hostname }}.conf
|
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
# Répondre aux demandes locales uniquement
|
|
||||||
local-service
|
|
||||||
|
|
||||||
# Ne pas transmettre les requêtes avec un nom court (pas FQDN)
|
# Ne pas transmettre les requêtes avec un nom court (pas FQDN)
|
||||||
domain-needed
|
domain-needed
|
||||||
|
|
||||||
{% if dnsmasq_bogus_priv_enabled %}
|
|
||||||
# Ne pas envoyer les requête sur les IP privées
|
# Ne pas envoyer les requête sur les IP privées
|
||||||
bogus-priv
|
bogus-priv
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# Spécifié le domaine pour qualifié les noms courts
|
# Spécifié le domaine pour qualifié les noms courts
|
||||||
domain={{ dnsmasq_domain }}
|
domain={{ dnsmasq_conf_domain }}
|
||||||
local=/{{ dnsmasq_domain }}/
|
local=/{{ dnsmasq_conf_domain }}/
|
||||||
|
|
||||||
# Ajoute le nom de domaine au noms simples
|
# Ajoute le nom de domaine au noms simples
|
||||||
expand-hosts
|
expand-hosts
|
||||||
@ -27,16 +22,11 @@ no-resolv
|
|||||||
# Ne pas utiliser /etc/hosts
|
# Ne pas utiliser /etc/hosts
|
||||||
no-hosts
|
no-hosts
|
||||||
|
|
||||||
# Définir les serveurs DNS à suivre
|
# Utiliser dnscrypt-proxy
|
||||||
{% for server in dnsmasq_servers %}
|
{% for server in dnsmasq_conf_servers %}
|
||||||
server={{ server }}
|
server={{ server }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
# Définir les serveurs DNS à suivre (PTR)
|
|
||||||
{% for server in dnsmasq_rev_servers %}
|
|
||||||
rev-server={{ server }}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
# Bloquer le rebond DNS
|
# Bloquer le rebond DNS
|
||||||
stop-dns-rebind
|
stop-dns-rebind
|
||||||
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
{% for ip in item.ips %}
|
|
||||||
{% set aliases = item.get('aliases', []) %}
|
|
||||||
{{ ip }} {{ ([item.hostname] + aliases) | join(' ') }}
|
|
||||||
{% endfor %}
|
|
Loading…
Reference in New Issue
Block a user