- name: Remove bind9 (not a suitable dnscache) packages apt: pkg={{ item }} state=absent purge=yes with_items: - bind9 when: with_dnscache - name: Install unbound (dnscache) packages apt: pkg={{ item }} state=installed update_cache=yes with_items: - unbound when: with_dnscache - name: Install resolv.conf template: src=dns/resolv.conf.j2 dest=/etc/resolv.conf owner=root group=root mode=0644 when: with_dnscache or (nameservers is defined and nameservers)