Ansible - Save changes made to iptables using the iptables_state module
by
Jeremy Canfield |
Updated: August 18 2022
| Ansible articles
If you are not familiar with modules, check out Ansible - Getting Started with Modules.
The iptables_state module is used to save changes made to iptables. The iptables_state module is part of the community.general collection, thus you may need to use the ansible-galaxy install command to install the community.general collection.
#]$ ansible-galaxy collection install community.general
Process install dependency map
Starting collection install process
Installing 'community.general:4.0.2' to '/home/john.doe/.ansible/collections/ansible_collections/community/general'
In this example, iptables will be saved to the /etc/sysconfig/iptables file.
- name: save iptables
community.general.iptables_state:
state: saved
path: /etc/sysconfig/iptables
Did you find this article helpful?
If so, consider buying me a coffee over at