# Rollback changes on error - name: Rollback /etc/named.conf.local copy: remote_src: true src: /etc/bind/named.conf.local.bak dest: /ect/bind/named.conf.local owner: bind group: bind mode: 0644 - name: Delete /etc/named.conf.local.bak file: path: /etc/named.conf.local.bak state: absent - name: Delete all changed zone files shell: "rm $(find {{bind9_zone_dir}} -not -name '*.bak' -type f)" changed_when: false - name: List all backed up zone files shell: "find {{bind9_zone_dir}} -name '*.bak' -type f -exec basename {} \\;" changed_when: false register: backup_zones_result - name: Restore backed up zone files shell: "mv {{bind9_zone_dir}}/{{item}}.bak {{bind9_zone_dir}}/{{item}}" with_items: backup_zones_result.stdout_lines