I have a firewall with about 50 rules and constantly growing. Is there a way I can create a playbook to test whether a source host can connect to a destination host on a specific port?
If that is possible I can create a playbook similar to my firewall rules so next time we make a change to the firewall, I can quickly validate all the rules using my ansible playbook.
Currently, my environment is Windows and Linux and telnet client is installed/enabled on every host.
Check out the wait_for module
https://docs.ansible.com/ansible/latest/wait_for_module.html
I had a chance to check the wait_for module. Let say my ansible controller is HOST3 and I have two other VMs, let’s call them HOST1 and HOST2. From my ansible controller (HOST3), can I create a playbook to check if HOST1 can connect to HOST2 over port 80? If that’s possible, is there an example that shows how this playbook should look like.
Thanks in advance.
-mm
If host1 is Linux yes, if it's Windows I don't know.
I tried your example and getting the following result. Is an inventory file needed since all the hosts being defined in the playbook?
[WARNING]: Could not match supplied host pattern, ignoring: all
[WARNING]: provided hosts list is empty, only localhost is available
[WARNING]: Could not match supplied host pattern, ignoring: HOST1
PLAY [HOST1] ********************************************************
skipping: no hosts matched
Yes, the playbook looks up hosts in the inventory file.