Skip to content

Instantly share code, notes, and snippets.

@gsluthra
Created May 4, 2014 11:46
Show Gist options
  • Save gsluthra/ae547a28e646408130e6 to your computer and use it in GitHub Desktop.
Save gsluthra/ae547a28e646408130e6 to your computer and use it in GitHub Desktop.
Puppet script to show how to open port 80 (HTTP) for incoming Apacahe Web requests via Puppet and iptables command on CentOS
### FIRE WALL ##########
exec { "open-port-80":
command => "sudo iptables -I INPUT 5 -m state --state NEW -p tcp --dport 80 -j ACCEPT",
path => "${os_path}",
unless => "sudo iptables-save | grep 80 | grep INPUT | grep ACCEPT | grep NEW | wc -l | xargs test 1 -eq",
notify => Exec["ip-tables-save"]
}
exec { "ip-tables-save":
command => "sudo service iptables save",
refreshonly => true,
path => "${os_path}",
}
@gsluthra
Copy link
Author

gsluthra commented May 4, 2014

I wrote a detailed explanation on this on my blog here: http://techie-notebook.blogspot.in/2014/05/using-puppet-to-open-port-80-through.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment