Skip to content

Instantly share code, notes, and snippets.

@linusthe3rd
Created July 12, 2012 17:17
Show Gist options
  • Save linusthe3rd/3099443 to your computer and use it in GitHub Desktop.
Save linusthe3rd/3099443 to your computer and use it in GitHub Desktop.
The commands needed to set an iptables configuration from an ERB template in Chef.
template "/etc/sysconfig/iptables" do
source "iptables.erb"
owner "root"
group "root"
mode "0600"
end
# Ensure that the iptables file adheres to the selinux requirements
execute "chcon" do
command "chcon system_u:object_r:system_conf_t:s0 /etc/sysconfig/iptables"
action :run
end
execute "service" do
command "service iptables save"
action :run
end
service "iptables" do
action :restart
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment