From ec27f453db6fe85499064813a46af07a3acf069a Mon Sep 17 00:00:00 2001 From: Alexandre Le Gall Date: Tue, 26 Sep 2023 11:12:29 +0200 Subject: [PATCH] =?UTF-8?q?[EVO]=20G=C3=A9rer=20des=20fichiers=20sp=C3=A9c?= =?UTF-8?q?ifiques?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++++ defaults/main.yml | 2 ++ tasks/configuration.yml | 18 ++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 34dfdc7..03f09b3 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,12 @@ Nom d'hôte du client. *Valeur par défaut: `{{ inventory_hostname }} {{ inventory_hostname_short }}`* +### dnsmasq_specifics + +Liste de dictionnaire contenant le nom de fichier et les éléments spécifiques au format `/etc/hosts`. + +*Valeur par défaut: aucune* + ## Exemple d'utilisation ### inventory.yml diff --git a/defaults/main.yml b/defaults/main.yml index 7a47c24..2b3f154 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -11,3 +11,5 @@ dnsmasq_host_aliases: [] dnsmasq_client_filename: "{{ inventory_hostname }}" dnsmasq_client_hostname: "{{ inventory_hostname }} {{ inventory_hostname_short }}" + +dnsmasq_specifics: [] diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 9147453..99766a5 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -13,10 +13,24 @@ - name: Déployer la configuration de l'instance ansible.builtin.template: + src: host.conf.j2 + dest: /srv/dnsmasq/{{ inventory_hostname }}.conf owner: dnsmasq group: root mode: u=rw,g=r,o=r - src: host.conf.j2 - dest: /srv/dnsmasq/{{ inventory_hostname }}.conf become: true notify: Recharger dnsmasq.service + +- name: Déployer les configurations specifiques + ansible.builtin.template: + src: specifics.j2 + dest: /srv/dnsmasq/{{ item.filename }}.conf + 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: "{{ item.filename }}"