[EVO] Gérer des fichiers spécifiques
This commit is contained in:
parent
201ae6d94a
commit
6258dd6d57
@ -46,6 +46,12 @@ 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
|
||||||
|
@ -11,3 +11,5 @@ 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: []
|
||||||
|
@ -13,10 +13,26 @@
|
|||||||
|
|
||||||
- name: Déployer la configuration de l'instance
|
- name: Déployer la configuration de l'instance
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
src: host.conf.j2
|
||||||
|
dest: /srv/dnsmasq/{{ inventory_hostname }}.conf
|
||||||
owner: dnsmasq
|
owner: dnsmasq
|
||||||
group: root
|
group: root
|
||||||
mode: u=rw,g=r,o=r
|
mode: u=rw,g=r,o=r
|
||||||
src: host.conf.j2
|
|
||||||
dest: /srv/dnsmasq/{{ inventory_hostname }}.conf
|
|
||||||
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
|
||||||
|
6
templates/specific.conf.j2
Normal file
6
templates/specific.conf.j2
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# {{ 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