Ansible - Save changes made to iptables using the iptables_state module

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 Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter a9689 in the box below so that we can be sure you are a human.