Created
May 4, 2014 11:46
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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}", | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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