# ufw or iptables module

**URL:** <https://forum.ansible.com/t/ufw-or-iptables-module/12337>\
**Category:** Ansible Project\
**Created:** [February 11, 2013, 9:15am UTC](https://forum.ansible.com/t/ufw-or-iptables-module/12337 "2013-02-11T09:15:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tin\_Tvrtkovic](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@Tin\_Tvrtkovic](https://forum.ansible.com/u/Tin_Tvrtkovic)\
**Post date:** [February 11, 2013, 9:15am UTC](https://forum.ansible.com/t/ufw-or-iptables-module/12337/1 "2013-02-11T09:15:34Z")

</div>

I’ve generally only needed to open up very specific ports on my hosts, nothing very complicated. For that I’ve used snippets like:

- name: ensure PostgreSQL main port is open  
shell: iptables -D INPUT -p tcp --dport 5432 -j ACCEPT; iptables -I INPUT -p tcp --dport 5432 -j ACCEPT && iptables-save

It’s kinda clumsy since you have to drop the rule first so they don’t pile up. I’d love an iptables module that’d make this more elegant. For my needs it needn’t be very complex.
