- name: Restart services
  service:
    name: "{{ item }}"
    state: restarted
    enabled: yes
  with_items:
    - nginx
    - nfs-kernel-server
    - dnsmasq
    - avahi-daemon
  become: yes

- name: Check services running
  service_facts:
  failed_when:
    ansible_facts.services[item].state != "running"
  with_items:
    - dnsmasq
    - nfs-kernel-server
    - nginx
    - avahi-daemon
  become: yes
