--- - name: Install required packages apt: state: present name: - dnsmasq - name: Configure dnsmasq template: src: dnsmasq.conf dest: "{{ global_dnsmasq_configuration_directory }}/0_main.conf" owner: root group: root mode: u=rw,g=r,o=r validate: "/usr/sbin/dnsmasq --test --conf-file=%s" notify: restart dnsmasq - meta: flush_handlers - name: Configure system to use dnsmasq template: src: resolv.conf dest: "{{ global_resolv_conf }}" owner: root group: root mode: u=r,g=r,o=r attributes: +i # immutable, may will let this task failing