[EVO] Utiliser l'inventaire d'ansible
This commit is contained in:
parent
b9baf12530
commit
90e0b3630c
@ -20,3 +20,17 @@
|
||||
dest: /srv/dnsmasq/{{ inventory_hostname }}.conf
|
||||
become: true
|
||||
notify: Recharger dnsmasq.service
|
||||
|
||||
- name: Déployer le fichier d'hôte en partant de l'inventaire
|
||||
# ansible.builtin.template:
|
||||
ansible.builtin.blockinfile:
|
||||
path: /srv/dnsmasq/ansible_inventory.conf.disabled
|
||||
marker: "# {mark} ANSIBLE MANAGED BLOCK for {{ inventory_hostname }} "
|
||||
owner: dnsmasq
|
||||
group: root
|
||||
mode: u=rw,g=r,o=r
|
||||
# src: hosts.conf.j2
|
||||
# dest: /srv/dnsmasq/ansible_inventory.conf.disabled
|
||||
become: true
|
||||
notify: Recharger dnsmasq.service
|
||||
loop: "{{ groups['all'] }}"
|
||||
|
6
templates/hosts.conf.j2
Normal file
6
templates/hosts.conf.j2
Normal file
@ -0,0 +1,6 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
{% for ip in dnsmasq_host_ips %}
|
||||
{% set hostnames = [hostvars[host]['inventory_hostname']] + [hostvars[host]['inventory_hostname_short']] + dnsmasq_host_aliases %}
|
||||
{{ ip }} {{ hostnames | select() | join(' ') }}
|
||||
{% endfor %}
|
Loading…
Reference in New Issue
Block a user