refactor: Change records file deployment
This commit is contained in:
parent
02056f9e6f
commit
bd8d50c06d
@ -16,7 +16,7 @@ dnsmasq_client_filename: "{{ inventory_hostname }}"
|
|||||||
dnsmasq_client_hostname: "{{ inventory_hostname }} {{ inventory_hostname_short }}"
|
dnsmasq_client_hostname: "{{ inventory_hostname }} {{ inventory_hostname_short }}"
|
||||||
|
|
||||||
# Groupe ansible pour l'enregistrement automatique
|
# Groupe ansible pour l'enregistrement automatique
|
||||||
dnsmasq_ansible_group: zone_gaia
|
dnsmasq_ansible_group: ""
|
||||||
|
|
||||||
# CIDR du sous-réseau IPv6
|
# CIDR du sous-réseau IPv6
|
||||||
dnsmasq_ipv6_subnet: ""
|
dnsmasq_ipv6_subnet: ""
|
||||||
|
@ -35,19 +35,3 @@
|
|||||||
mode: u=rw,g=r,o=r
|
mode: u=rw,g=r,o=r
|
||||||
become: true
|
become: true
|
||||||
notify: Reload dnsmasq.service
|
notify: Reload dnsmasq.service
|
||||||
|
|
||||||
- name: Deploy specific configuration
|
|
||||||
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: Reload dnsmasq.service
|
|
||||||
loop: "{{ dnsmasq_specifics }}"
|
|
||||||
loop_control:
|
|
||||||
label: "{{ filename }}"
|
|
||||||
vars:
|
|
||||||
filename: /srv/dnsmasq/{{ item.hostname }}.conf
|
|
||||||
|
@ -8,3 +8,7 @@
|
|||||||
- name: Import configuration tasks
|
- name: Import configuration tasks
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: configuration.yml
|
file: configuration.yml
|
||||||
|
|
||||||
|
- name: Import records deployment tasks
|
||||||
|
ansible.builtin.import_tasks:
|
||||||
|
file: records.yml
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
- name: Deploy records
|
- name: Deploy records
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
src: "{{ role_path }}/templates/auto.conf.j2"
|
||||||
|
dest: /srv/dnsmasq/auto-{{ dnsmasq_ansible_group }}.conf
|
||||||
owner: dnsmasq
|
owner: dnsmasq
|
||||||
group: root
|
group: root
|
||||||
mode: u=rw,g=r,o=r
|
mode: u=rw,g=r,o=r
|
||||||
src: "{{ role_path }}/templates/auto.conf.j2"
|
|
||||||
dest: /srv/dnsmasq/auto_{{ dnsmasq_ansible_group }}.conf
|
|
||||||
when: dnsmasq_hosts | length > 0
|
when: dnsmasq_hosts | length > 0
|
||||||
become: true
|
become: true
|
||||||
delegate_to: "{{ dnsserver }}"
|
delegate_to: "{{ dnsserver }}"
|
@ -1,12 +1,22 @@
|
|||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
{% for host in groups[dnsmasq_ansible_group] %}
|
# ansible inventory
|
||||||
|
{%- for host in (groups[dnsmasq_ansible_group] | sort) %}
|
||||||
{%- set ipv4 = hostvars[host]['ansible_host'] %}
|
{%- set ipv4 = hostvars[host]['ansible_host'] %}
|
||||||
|
{%- set ipv6_prefix = dnsmasq_ipv6_subnet | split('/') | first %}
|
||||||
{%- set ipv6_suffix = hostvars[host]['ansible_host'] | split('.') | last %}
|
{%- set ipv6_suffix = hostvars[host]['ansible_host'] | split('.') | last %}
|
||||||
{%- set ipv6 = (dnsmasq_ipv6_subnet | split('/') | first) + ipv6_suffix %}
|
|
||||||
{%- set aliases = [host] + hostvars[host].get('dnsmasq_host_aliases', []) %}
|
{%- set aliases = [host] + hostvars[host].get('dnsmasq_host_aliases', []) %}
|
||||||
|
|
||||||
# {{ host }}
|
## {{ host }}
|
||||||
{{ ipv4 }} {{ aliases | join(' ') }}
|
{{ ipv4 }} {{ aliases | join(' ') }}
|
||||||
{{ ipv6 }} {{ aliases | join(' ') }}
|
{{ ipv6_prefix }}{{ ipv6_suffix }} {{ aliases | join(' ') }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
# role specifics
|
||||||
|
{%- for specific in dnsmasq_specifics %}
|
||||||
|
|
||||||
|
## {{ specific.hostname }}
|
||||||
|
{% for ip in specific.ips %}
|
||||||
|
{{ ip }} {{ specific.hostname }}
|
||||||
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -1,17 +1,8 @@
|
|||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
{% for specific in dnsmasq_specifics %}
|
||||||
|
|
||||||
{% for host in groups['zone_gaia'] %}
|
# {{ specific.hostname }}
|
||||||
{%- set ipv4 = hostvars[host]['ansible_host'] %}
|
{% for ip in specific.ips %}
|
||||||
{%- set ipv6_suffix = hostvars[host]['ansible_host'] | split('.') | last %}
|
{{ ip }} {{ specific.hostname }}
|
||||||
{%- set aliases = [host] + hostvars[host].get('dnsmasq_host_aliases', []) %}
|
{% endfor %}
|
||||||
|
|
||||||
# {{ host }}
|
|
||||||
{{ ipv4 }} {{ aliases | join(' ') }}
|
|
||||||
{% if (ipv6_suffix | int) < 10 %}
|
|
||||||
2a01:e0a:ee5:8b0::d00{{ ipv6_suffix }} {{ aliases | join(' ') }}
|
|
||||||
{% elif (ipv6_suffix | int) < 100 %}
|
|
||||||
2a01:e0a:ee5:8b0::d0{{ ipv6_suffix }} {{ aliases | join(' ') }}
|
|
||||||
{% else %}
|
|
||||||
2a01:e0a:ee5:8b0::d{{ ipv6_suffix }} {{ aliases | join(' ') }}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
{% for host in group['zone_gaia'] %}
|
|
||||||
# {{ inventory_hostname }}
|
|
||||||
192.168.84.{{ proxmox_host_id }} {{ inventory_hostname }} {{ inventory_hostname_short }} {{ dnsmasq_host_aliases | join(' ') }}
|
|
||||||
2a01:cb00:131:f100::d0{{ proxmox_host_id }} {{ inventory_hostname }} {{ inventory_hostname_short }} {{ dnsmasq_host_aliases | join(' ') }}
|
|
||||||
{% endfor %}
|
|
Loading…
x
Reference in New Issue
Block a user