--- - name: Install required packages apt: state: present name: - bind9 - name: Create directory for zone databases file: path: "{{ dns_zones_directory }}" state: directory - name: Configure bind9 options template: src: named.conf.options dest: "{{ dns_options_configuration }}" owner: root group: root mode: "u=rw,g=r,o=r" notify: reload bind9 - name: Enable bind9 service systemd: name: bind9 state: started enabled: yes - name: Allow dns in firewall ufw: rule: allow port: 53 proto: "{{ item }}" loop: - tcp - udp