--- - name: create named.conf.local for primary template: src: ../templates/named.conf.local.primary.j2 dest: /etc/bind/named.conf.local when: inventory_hostname in groups['dnsprimary'] - name: create primary zone files for primary template: src: "../templates/{{ item.zone_file }}.j2" dest: "/etc/bind/{{ item.zone_file }}" with_items: "{{ dns_zones }}" when: inventory_hostname in groups['dnsprimary'] - name: create named.conf.local for replica template: src: ../templates/named.conf.local.replica.j2 dest: /etc/bind/named.conf.local when: inventory_hostname in groups['dnsreplica'] - name: restart bind9 service: name: bind9 state: restarted enabled: true