- name: 'Remove bind9 (not a suitable dnscache) packages' apt: pkg: - 'bind9' state: 'absent' purge: 'yes' when: with_dnscache|bool tags: - 'dns' - name: 'Install unbound (dnscache) packages' apt: pkg: - 'unbound' state: 'present' when: with_dnscache|bool tags: - 'dns' - name: 'Install resolv.conf' template: src: 'dns/resolv.conf.j2' dest: '/etc/resolv.conf' owner: 'root' group: 'root' mode: '0644' when: with_dnscache|bool or (nameservers is defined and nameservers|length > 0) tags: - 'dns' # vim: ft=yaml.ansible