Gathers facts from all hosts defined in a specific inventory file:
ansible all -i ../<inventory_file> -u ubuntu -m setup
Content changed to trigger the restart of nginx:
- name: web content task
.......
register: content_result
- name: Restart nginx if content is changed
service:
name: nginx
state: restarted
when: content_result.changed