36 lines
925 B
YAML
36 lines
925 B
YAML
# Backup bind9 config and zone files for potential rollback
|
|
|
|
- name: Ensure dir {{bind9_zone_dir}} exists
|
|
file:
|
|
path: /srv/dns
|
|
owner: bind
|
|
group: bind
|
|
mode: u+rwx
|
|
state: directory
|
|
register: dns_dir_result
|
|
|
|
- set_fact:
|
|
bind9_initial_setup: "{{dns_dir_result.changed}}"
|
|
|
|
- name: List all existing zone files
|
|
shell: "find {{ bind9_zone_dir }} -type f -exec basename {} \\;"
|
|
changed_when: false
|
|
register: existing_zones_result
|
|
|
|
|
|
- debug: "msg={{bind9_initial_setup}}"
|
|
- debug: "msg={{existing_zones_result.stdout_lines}}"
|
|
|
|
- name: Backup /etc/bind/named.conf.local
|
|
become: true
|
|
copy:
|
|
remote_src: true
|
|
src: /etc/bind/named.conf.local
|
|
dest: /etc/bind/named.conf.local.bak
|
|
when: not bind9_initial_setup
|
|
|
|
|
|
- name: Backup existing zone files
|
|
shell: "mv {{bind9_zone_dir}}/{{item}} {{bind9_zone_dir}}/{{item}}.bak"
|
|
with_items: result.stdout_lines
|
|
when: not bind9_initial_setup |