# Firewall Rules Check with Ansible

**URL:** <https://forum.ansible.com/t/firewall-rules-check-with-ansible/26829>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [February 22, 2018, 9:26pm UTC](https://forum.ansible.com/t/firewall-rules-check-with-ansible/26829 "2018-02-22T21:26:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcalfa1](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@marcalfa1](https://forum.ansible.com/u/marcalfa1)\
**Post date:** [February 22, 2018, 9:26pm UTC](https://forum.ansible.com/t/firewall-rules-check-with-ansible/26829/1 "2018-02-22T21:26:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 22, 2018, 10:00pm UTC](https://forum.ansible.com/t/firewall-rules-check-with-ansible/26829/2 "2018-02-22T22:00:24Z")

</div>

Check out the wait\_for module  
[https://docs.ansible.com/ansible/latest/wait\_for\_module.html](https://docs.ansible.com/ansible/latest/wait_for_module.html)

---

<div class="post-metadata">

**Author:** ![marcalfa1](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@marcalfa1](https://forum.ansible.com/u/marcalfa1)\
**Post date:** [February 25, 2018, 3:23am UTC](https://forum.ansible.com/t/firewall-rules-check-with-ansible/26829/3 "2018-02-25T03:23:34Z")

</div>



---

<div class="post-metadata">

**Author:** ![marcalfa1](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@marcalfa1](https://forum.ansible.com/u/marcalfa1)\
**Post date:** [February 25, 2018, 3:23am UTC](https://forum.ansible.com/t/firewall-rules-check-with-ansible/26829/4 "2018-02-25T03:23:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 25, 2018, 7:32am UTC](https://forum.ansible.com/t/firewall-rules-check-with-ansible/26829/5 "2018-02-25T07:32:48Z")

</div>

If host1 is Linux yes, if it's Windows I don't know.

---

<div class="post-metadata">

**Author:** ![marcalfa1](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@marcalfa1](https://forum.ansible.com/u/marcalfa1)\
**Post date:** [February 25, 2018, 9:53pm UTC](https://forum.ansible.com/t/firewall-rules-check-with-ansible/26829/6 "2018-02-25T21:53:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Varun\_Chopra](https://avatars.discourse-cdn.com/v4/letter/v/54ee81/32.png) [@Varun\_Chopra](https://forum.ansible.com/u/Varun_Chopra)\
**Post date:** [February 26, 2018, 11:05am UTC](https://forum.ansible.com/t/firewall-rules-check-with-ansible/26829/7 "2018-02-26T11:05:13Z")

</div>

Yes, the playbook looks up hosts in the inventory file.
