- name: "url monitor and restart if its down"
hosts: servers
gather_facts: no
tasks:
- name: "Check 8101 instances is running on {{ inventory_hostname }}"
uri:
url: "http://{{inventory_hostname}}:8101/health"
register: result_01
- name: status code
debug:
var: result_01.status
- name: "Restart instance on {{ inventory_hostname }} "
shell: restart.sh
when: result_01.status != 200
When the url is down, restart task is not executing. getting below error.
FAILED! => {“ansible_facts”: {“discovered_interpreter_python”: “/usr/bin/python”}, “changed”: false, “contentand not [200]: Request failed: <urlopen error [Errno 111] Connection refused>”, “redirected”: false, “status”: -1,
Could someone help on this