---
- name: dns | install dnsmasq
  apt: name=dnsmasq update_cache=yes cache_valid_time=86400

- name: dns | configure dnsmasq
  template: src=dnsmasq.conf dest=/etc/dnsmasq.d/10-{{ consul_service_name }}
  register: dnsmasq_config_result

- name: dns | tell dhclient to use prefer dnsmasq
  command: "sed /etc/dhcp/dhclient.conf -i -e 's/#\\(prepend domain-name-servers 127\\.0\\.0\\.1;\\)/\\1/'"
  ignore_errors: yes
  tags: [dhclient]

- name: dns | start/reload dnsmasq
  service: name=dnsmasq state=reloaded enabled=true
  when: dnsmasq_config_result.changed

---
- name: dns | install dnsmasq
  apt: name=dnsmasq update_cache=yes cache_valid_time=86400

- name: dns | configure dnsmasq
  template: src=dnsmasq.conf dest=/etc/dnsmasq.d/10-{{ consul_service_name }}
  register: dnsmasq_config_result

- name: dns | tell dhclient to use prefer dnsmasq
  command: "sed /etc/dhcp/dhclient.conf -i -e 's/#\\(prepend domain-name-servers 127\\.0\\.0\\.1;\\)/\\1/'"
  ignore_errors: yes
  changed_when: False
  tags: [dhclient]

- name: dns | start/reload dnsmasq
  service: name=dnsmasq state=reloaded enabled=true
  when: dnsmasq_config_result.changed

Set `changed_when` because there is no good way (at the moment) to determine if this task was idempotent
Set `changed_when` because there is no good way (at the moment) to determine if this task was idempotent
