Question:
I want to test if the host I am provisioning can reach a specific server and connect to a specific TCP port. If it can’t the playbook should fail.
How can I do that?
Answer:
There is wait_for module for this.
To check that target.host
can access remote.host:8080
:
1 2 3 4 5 |
- hosts: target.host tasks: - wait_for: host=remote.host port=8080 timeout=1 - debug: msg=ok |
There are a lot of other examples in the documentation.