salt.modules.iptables is great to use from command line but how can I use this in a state file.
First I want to check if iptables is running:
check_process:
cmd.run:
- name: ps aux | grep 'iptables'
Return True
If true: Then I will use salt.modules.iptables
salt 'myhost.domain.local' iptables.check filter INPUT rule='-m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT'
If false
salt 'myhost.domain.local' iptables.insert filter INPUT rule='-m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT'
Thanks for your information