dns: Transfered master zones from makefile approach to dynamic updates approach
parent
0232319ccd
commit
ae42f963a2
@ -1,5 +0,0 @@
|
||||
---
|
||||
|
||||
- name: reload apparmor profile
|
||||
command: "/usr/sbin/apparmor_parser -r {{ apparmor_profile }}"
|
||||
notify: restart bind9
|
@ -1,10 +0,0 @@
|
||||
{{ zones_directory }}/* rw,
|
||||
{{ zones_directory }}/*/tmp-* rwk,
|
||||
# Journal files required by Bind to save temporary changes
|
||||
{{ zones_directory }}/*/zone.db.jbk rwk,
|
||||
{{ zones_directory }}/*/zone.db.jnl rwk,
|
||||
{{ zones_directory }}/*/zone.db.jnw rwk,
|
||||
{{ zones_directory }}/*/zone.db.signed rwk,
|
||||
{{ zones_directory }}/*/zone.db.signed.jbk rwk,
|
||||
{{ zones_directory }}/*/zone.db.signed.jnl rwk,
|
||||
{{ zones_directory }}/*/zone.db.signed.jnw rwk,
|
@ -1,11 +0,0 @@
|
||||
dest:={{ zones_environment_link_name }}
|
||||
db_name:={{ zones_environment_database_name }}
|
||||
|
||||
zone_dirs:=$(wildcard *.*/)
|
||||
zones:=$(zone_dirs:/=)
|
||||
|
||||
.PHONY: all
|
||||
all: $(addprefix ${dest}/,$(addsuffix /${db_name},${zones}))
|
||||
|
||||
${dest}/%/${db_name}: %/*.db
|
||||
cat $(sort $^) | sed '0,/^ 0$$/s// '"$$(($$(date +%s) / 60))"'/' > "$@";
|
@ -1,25 +1,34 @@
|
||||
---
|
||||
|
||||
- name: Store dns entries at dns host
|
||||
- name: Store changes in dns entries locally
|
||||
copy:
|
||||
content: "{{ entries }}"
|
||||
dest: "{{ domain_zone_file }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: u=rw,g=r,o=
|
||||
register: result_store_entries
|
||||
delegate_to: "{{ dns_system_domain }}"
|
||||
|
||||
- name: Rebuild zone files
|
||||
make:
|
||||
chdir: "{{ global_dns_zones_environment_directory }}"
|
||||
when: result_store_entries.changed
|
||||
register: result_rebuild_zone
|
||||
delegate_to: "{{ dns_system_domain }}"
|
||||
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: Reload bind9
|
||||
systemd:
|
||||
name: "{{ global_bind_service_name }}"
|
||||
state: reloaded
|
||||
when: result_rebuild_zone.changed
|
||||
- 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
|
||||
tags:
|
||||
- dns_entries
|
||||
|
@ -1,3 +0,0 @@
|
||||
---
|
||||
|
||||
domain_environment_directory: "{{ global_dns_zones_environment_directory }}/{{ dns_zone_domain }}" # Given by dns/master
|
@ -1,3 +0,0 @@
|
||||
---
|
||||
|
||||
domain_environment_directory: "{{ global_dns_zones_environment_directory }}/{{ domain }}" # Fixed for usage in other roles
|
Loading…
Reference in New Issue