Ansible check if port is listening
Ansible check if port is listening
- name: Check if port 80 is listening
wait_for:
port: 80
delay: 5
timeout: 10
msg: "Timeout waiting for 80 to respond"
register: port_check
ignore_errors: yes
- name: Try to restart httpd if not started
service: name=httpd state=started enabled=yes
when: port_check.failed == true