- name: copy zone copy: src: "/etc/powerdns/tpl/{{ item.item }}" dest: "/etc/powerdns/zones/db.{{ item.item }}" remote_src: yes with_items: "{{ zonefilestask.results }}" loop_control: label: "{{ item.item }}" when: item.changed - name: set zone serial replace: regexp: "##sequence##" replace: "{{ ansible_date_time.epoch }}" dest: "/etc/powerdns/zones/db.{{ item.item }}" with_items: "{{ zonefilestask.results }}" loop_control: label: "{{ item.item }}" when: item.changed - name: restart powerdns service: name=pdns state=restarted register: powerdns_restarted - name: reload changed zones command: "pdns_control bind-reload-now {{ zonefilestask.results|selectattr('changed')|join(' ', attribute='item') }}" when: not powerdns_restarted | default(False) - name: purge cache command: "pdns_control purge" when: not powerdns_restarted | default(False) - name: notify slaves command: "pdns_control notify {{ item.item }}" with_items: "{{ zonefilestask.results }}" loop_control: label: "{{ item.item }}" when: item.changed