Puppet Class: iptables
- Defined in:
- manifests/init.pp
Summary
Manage iptables with default rule optimization and a failsafe fallback modeOverview
> It is **highly recommended** that you place this module in “firewalld“ > mode if the underlying system supports it. > > You can do this by setting “iptables::use_firewalld: true“ in Hiera
This class will detect conflicts with the SIMP option “simp_options::firewall“ and, if necessary, cease management of IPTables in the case of a conflict.
In particular, this means that if “simp_options::firewall“ is “false“, but you have included this class, it will refuse to manage IPTables and will instead raise a warning.
If the “simp_options::firewall“ variable is not present, the module will manage IPTables as expected.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'manifests/init.pp', line 106
class iptables (
Variant[Enum['ignore','firewalld'],Boolean] $enable = simplib::lookup('simp_options::firewall', { 'default_value' => true }),
Boolean $use_firewalld = true,
String $ensure = simplib::lookup('simp_options::package_ensure', { 'default_value' => 'installed' }),
Boolean $ipv6 = true,
Boolean $class_debug = false,
Boolean $optimize_rules = true,
Boolean $precise_match = false,
Array[String[1]] $ignore = [],
Boolean $default_rules = true,
Boolean $scanblock = false,
Boolean $prevent_localhost_spoofing = true,
Optional[Hash] $ports = undef
) {
simplib::assert_metadata($module_name)
if $enable != 'ignore' {
# This is required in case you want to put firewalld in iptables mode
contain 'iptables::install'
if $use_firewalld {
simplib::assert_optional_dependency($module_name, 'simp/simp_firewalld')
include 'simp_firewalld'
if $ports {
iptables::ports {'firewalld':
ports => $ports
}
}
} else {
contain 'iptables::service'
if $default_rules { contain 'iptables::rules::base' }
if $scanblock { contain 'iptables::rules::scanblock' }
if $prevent_localhost_spoofing { contain 'iptables::rules::prevent_localhost_spoofing' }
contain 'iptables::rules::default_drop'
Class['iptables::install'] -> Class['iptables::service']
file { '/etc/sysconfig/iptables':
owner => 'root',
group => 'root',
mode => '0640',
require => Class['iptables::install']
}
# These are required to run if you are managing iptables with the custom
# types at all.
iptables_optimize { '/etc/sysconfig/iptables':
optimize => $optimize_rules,
ignore => $ignore,
disable => !$enable,
precise_match => $precise_match,
require => Class['iptables::install']
}
if $ipv6 and $facts['ipv6_enabled'] {
file { '/etc/sysconfig/ip6tables':
owner => 'root',
group => 'root',
mode => '0640',
require => Class['iptables::install']
}
ip6tables_optimize { '/etc/sysconfig/ip6tables':
optimize => $optimize_rules,
ignore => $ignore,
disable => !$enable,
precise_match => $precise_match,
require => Class['iptables::install']
}
}
if $ports {
iptables::ports {'iptables':
ports => $ports,
require => Class['iptables::install']
}
}
}
}
}
|