Skip to content

Instantly share code, notes, and snippets.

@tlk2126
Created June 10, 2014 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlk2126/9582c16c65a55ca305dd to your computer and use it in GitHub Desktop.
Save tlk2126/9582c16c65a55ca305dd to your computer and use it in GitHub Desktop.
CUL Handling of iptables rules within individual states, using Salt Stack
iptables:
pkg:
- installed
service:
- running
- enable: True
- reload: True
- require:
- pkg: iptables
/etc/sysconfig/iptables.d:
file:
- directory
- user: root
- group: root
- mode: 550
- require:
- pkg: iptables
iptables_update:
cmd:
- wait
- name: /usr/bin/salt-compose-file /etc/sysconfig/iptables.d/ iptables /etc/sysconfig/iptables
- stateful: True
- watch_in:
- service: iptables
- require:
- file: /usr/bin/salt-compose-file
# /usr/bin/salt-compose file <source dir> <look for files ending in .this> <output to this file>
# In source dir, cat together everything ending in .<this>, if the generated file is different
# than <output to this file>, replace it. The output of the command follows the Salt `stateful'
# protocol
# Example use
# IPTables Rules
/etc/sysconfig/iptables.d/50-mail-server.iptables:
file:
- managed
- user: root
- group: root
- mode: 444
- source: salt://mailserver/50-mail-server.iptables
- template: jinja
- require:
- file: /etc/sysconfig/iptables.d
- watch_in:
- cmd: iptables_update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment