You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.3 KiB
YAML

---
- name: Store changes in dns entries locally
copy:
content: |
#jinja2:trim_blocks: False
zone {{ dns_zone_domain }}.
ttl {{ ttl_default }}
{%- if entries_delete %}{% for entry in entries %}{% if entry|mapping %}
update delete {{ entry.domain | default('@') | domain_relative_to(domain) }} 0 {{ entry.class | default('IN') }}{% if not entries_delete_all_types %} {{ entry.type }}{% endif %}
{%- endif %}{% endfor %}{% endif %}
{% for entry in entries %}{% if entry|mapping -%}
update add {{ entry.domain | default('@') | domain_relative_to(domain) }} {{ entry.ttl | default(ttl_default) }} {{ entry.class | default('IN') }} {{ entry.type }} {{ entry.data }}
{% else -%}
{% if not entry|regex_search('^(update )?(add|del(ete)?) ') %}update add {% endif %}{{ entry }}
{% endif %}{% endfor %}
send
dest: "{{ local_file }}"
owner: "{{ global_local_user }}"
group: "{{ global_local_user }}"
mode: u=rw,g=r,o=r
delegate_to: localhost
register: entries_changes_file
tags:
- dns_entries
- name: Update dns entries at dns host
command:
cmd: nsupdate -l # local mode
stdin: "{{ lookup('file', local_file) }}\n"
delegate_to: "{{ dns_system_domain }}"
when: entries_changes_file.changed and not ansible_check_mode
tags:
- dns_entries