Skip to content

Commit

Permalink
Use firewalld by default
Browse files Browse the repository at this point in the history
* Mark `iptables::use_firewalld()` function deprecated
* Drop support for EOL operating systems
* Bump version to 7.0.0 since this is a breaking change
  • Loading branch information
silug committed Aug 28, 2024
1 parent e342e07 commit 23b4736
Show file tree
Hide file tree
Showing 23 changed files with 196 additions and 128 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
* Mon Aug 19 2024 Steven Pritchard <steve@sicura.us> - 7.0.0
- Use firewalld by default
- Drop use of `iptables::use_firewalld` function
- Mark `iptables::use_firewalld` function deprecated
- Drop EL7 support

* Wed Jan 17 2024 Richard Gardner <rick@sicura.us> - 6.13.1
- Fixed missing update to hiera.yaml for puppet 8 support

Expand Down
8 changes: 4 additions & 4 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
### Functions

* [`iptables::slice_ports`](#iptables--slice_ports): Split a stringified Iptables::DestPort into an Array that contain groupings of `max_length` size.
* [`iptables::use_firewalld`](#iptables--use_firewalld): Returns ``true`` if the client can/should use firewalld
* [`iptables::use_firewalld`](#iptables--use_firewalld): **DEPRECATED** Returns ``true`` if the client can/should use firewalld

### Data types

Expand Down Expand Up @@ -104,7 +104,7 @@ Explicitly enable management via ``simp_firewalld``

* Systems that do not have ``firewalld`` installed will fall back to ``iptables``

Default value: `iptables::use_firewalld($enable)`
Default value: `true`

##### <a name="-iptables--ensure"></a>`ensure`

Expand Down Expand Up @@ -1761,11 +1761,11 @@ The maximum length of each group.

Type: Puppet Language

Returns ``true`` if the client can/should use firewalld
**DEPRECATED** Returns ``true`` if the client can/should use firewalld

#### `iptables::use_firewalld(Variant[String[1], Boolean] $enable = true)`

Returns ``true`` if the client can/should use firewalld
**DEPRECATED** Returns ``true`` if the client can/should use firewalld

Returns: `Boolean`

Expand Down
1 change: 1 addition & 0 deletions data/os/Amazon-2.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
iptables::install::ipv4_package: iptables-services
iptables::install::ipv6_package: iptables-services
iptables::use_firewalld: false
3 changes: 0 additions & 3 deletions data/os/CentOS-7.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/os/OracleLinux-7.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions data/os/RedHat-7.yaml

This file was deleted.

9 changes: 5 additions & 4 deletions functions/use_firewalld.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Returns ``true`` if the client can/should use firewalld
# **DEPRECATED** Returns ``true`` if the client can/should use firewalld
#
# @param enable
# The type of enablement to use
Expand All @@ -9,9 +9,10 @@
#
# @return [Boolean]
#
function iptables::use_firewalld(
Variant[String[1], Boolean] $enable = true
) {
function iptables::use_firewalld (
Variant[String[1], Boolean] $enable = true,
) >> Boolean {
deprecation('iptables::use_firewalld', 'iptables::use_firewalld is deprecated')

$_firewalld_os_list = {
'RedHat' => '8',
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
#
class iptables (
Variant[Enum['ignore','firewalld'],Boolean] $enable = simplib::lookup('simp_options::firewall', { 'default_value' => true }),
Boolean $use_firewalld = iptables::use_firewalld($enable),
Boolean $use_firewalld = true,
String $ensure = simplib::lookup('simp_options::package_ensure', { 'default_value' => 'installed' }),
Boolean $ipv6 = true,
Boolean $class_debug = false,
Expand Down
6 changes: 1 addition & 5 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-iptables",
"version": "6.13.1",
"version": "7.0.0",
"author": "SIMP Team",
"summary": "Safely manages IPTables firewall rules",
"license": "Apache-2.0",
Expand Down Expand Up @@ -37,23 +37,19 @@
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"7",
"8",
"9"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"7",
"8",
"9"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"7",
"8",
"9"
]
Expand Down
14 changes: 14 additions & 0 deletions spec/acceptance/nodesets/almalinux8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
HOSTS:
almalinux8:
roles:
- default
- firewalld
platform: el-8-x86_64
box: almalinux/8
hypervisor: <%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>
CONFIG:
type: aio
log_level: verbose
synced_folder: disabled
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'puppet7') %>"
15 changes: 15 additions & 0 deletions spec/acceptance/nodesets/almalinux9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
HOSTS:
almalinux9:
roles:
- default
- firewalld
platform: el-9-x86_64
box: almalinux/9
hypervisor: <%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>
CONFIG:
type: aio
vagrant_memsize: 2048
log_level: verbose
synced_folder: disabled
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'puppet7') %>"
19 changes: 6 additions & 13 deletions spec/acceptance/nodesets/amzn2.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
<%
if ENV['BEAKER_HYPERVISOR']
hypervisor = ENV['BEAKER_HYPERVISOR']
else
hypervisor = 'vagrant'
end
-%>
---
HOSTS:
amzn2:
roles:
- default
- iptables
platform: el-7-x86_64
box: gbailey/amzn2
hypervisor: <%= hypervisor %>
hypervisor: <%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>

CONFIG:
log_level: verbose
synced_folder : disabled
synced_folder: disabled
type: aio
vagrant_memsize: 512
<% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
<% end -%>
vagrant_memsize: 1024
puppet_collection: <%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'puppet7') %>
17 changes: 17 additions & 0 deletions spec/acceptance/nodesets/centos9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
HOSTS:
centos9:
roles:
- default
- firewalld
platform: el-9-x86_64
box: generic/centos9s
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
family: centos-cloud/centos-stream-9
gce_machine_type: n1-standard-1
CONFIG:
type: aio
vagrant_memsize: 1024
log_level: verbose
synced_folder: disabled
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'puppet7') %>"
25 changes: 8 additions & 17 deletions spec/acceptance/nodesets/default.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
---
HOSTS:
el7:
rocky9:
roles:
- default
- iptables
- firewalld
platform: el-7-x86_64
box: centos/7
- default
- firewalld
platform: el-9-x86_64
box: generic/rocky9
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
family: centos-cloud/centos-7
gce_machine_type: n1-standard-2
el8:
roles:
- firewalld
platform: el-8-x86_64
box: generic/centos8
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
family: centos-cloud/centos-stream-8
gce_machine_type: n1-standard-2
family: rocky-linux-cloud/rocky-linux-9
gce_machine_type: n1-standard-1
CONFIG:
type: aio
vagrant_memsize: 256
vagrant_memsize: 1024
log_level: verbose
synced_folder: disabled
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'puppet7') %>"
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
---
HOSTS:
oel7:
roles:
- default
- iptables
- firewalld
platform: el-7-x86_64
box: generic/oracle7
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
family: sicura-image-build/oracle-linux-7
gce_machine_type: n1-standard-2
oel8:
roles:
- firewalld
- default
- firewalld
platform: el-8-x86_64
box: generic/oracle8
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
family: sicura-image-build/oracle-linux-8
gce_machine_type: n1-standard-2
gce_machine_type: n1-standard-1
CONFIG:
type: aio
vagrant_memsize: 256
vagrant_memsize: 1024
log_level: verbose
synced_folder: disabled
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'puppet7') %>"
17 changes: 17 additions & 0 deletions spec/acceptance/nodesets/oel9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
HOSTS:
oel9:
roles:
- default
- firewalld
platform: el-9-x86_64
box: generic/oracle9
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
family: sicura-image-build/oracle-linux-9
gce_machine_type: n1-standard-1
CONFIG:
type: aio
vagrant_memsize: 1024
log_level: verbose
synced_folder: disabled
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'puppet7') %>"
10 changes: 5 additions & 5 deletions spec/acceptance/nodesets/rhel8.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
HOSTS:
server-el8:
rhel8:
roles:
- default
- firewalld
- default
- firewalld
platform: el-8-x86_64
box: generic/rhel8
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
yum_repos:
epel:
mirrorlist: https://mirrors.fedoraproject.org/metalink?repo=epel-8&arch=$basearch
gpgkeys:
- https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
- https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
family: rhel-cloud/rhel-8
gce_machine_type: n1-standard-2
gce_machine_type: n1-standard-1
CONFIG:
log_level: verbose
type: aio
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
---
HOSTS:
server-el7:
rhel9:
roles:
- default
- iptables
- firewalld
platform: el-7-x86_64
box: generic/rhel7
- default
- firewalld
platform: el-9-x86_64
box: generic/rhel9
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
yum_repos:
epel:
mirrorlist: https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
mirrorlist: https://mirrors.fedoraproject.org/metalink?repo=epel-9&arch=$basearch
gpgkeys:
- https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
family: rhel-cloud/rhel-7
gce_machine_type: n1-standard-2
- https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-9
family: rhel-cloud/rhel-9
gce_machine_type: n1-standard-1
CONFIG:
validate: false
log_level: verbose
Expand Down
17 changes: 17 additions & 0 deletions spec/acceptance/nodesets/rocky8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
HOSTS:
rocky8:
roles:
- default
- firewalld
platform: el-8-x86_64
box: generic/rocky8
hypervisor: "<%= ENV.fetch('BEAKER_HYPERVISOR', 'vagrant') %>"
family: rocky-linux-cloud/rocky-linux-8
gce_machine_type: n1-standard-1
CONFIG:
type: aio
vagrant_memsize: 1024
log_level: verbose
synced_folder: disabled
puppet_collection: "<%= ENV.fetch('BEAKER_PUPPET_COLLECTION', 'puppet7') %>"
28 changes: 26 additions & 2 deletions spec/acceptance/suites/default/00_default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
test_name "iptables class"

hosts.each do |host|
next unless host[:roles].include?('iptables')
unless host[:roles].include?('iptables')
describe 'iptables' do
context host.to_s do
it 'skips default test suite' do
true
end
end
end

next
end

describe "iptables class #{host}" do
before(:context) do
Expand Down Expand Up @@ -148,7 +158,21 @@ class { 'iptables': scanblock => true}

it 'should configure xt_recent kernel module using hieradata overrides' do
set_hieradata_on(host, hieradata_with_overrides)
apply_manifest_on(host, manifest_with_scanblock_enabled, :catch_failures => true)

# FIXME: On at least Amazon Linux 2, this will fail with a number of errors:
# Error: Input/output error @ fptr_finalize_flush - /sys/module/xt_recent/parameters/ip_list_tot
# Error: /Stage[main]/Iptables::Rules::Mod_recent/Xt_recent[/sys/module/xt_recent/parameters]/ip_list_tot: change from '200' to 400 failed: Input/output error @ fptr_finalize_flush - /sys/module/xt_recent/parameters/ip_list_tot
# Error: Input/output error @ fptr_finalize_flush - /sys/module/xt_recent/parameters/ip_pkt_list_tot
# Error: /Stage[main]/Iptables::Rules::Mod_recent/Xt_recent[/sys/module/xt_recent/parameters]/ip_pkt_list_tot: change from '20' to 40 failed: Input/output error @ fptr_finalize_flush - /sys/module/xt_recent/parameters/ip_pkt_list_tot
# Error: Input/output error @ fptr_finalize_flush - /sys/module/xt_recent/parameters/ip_list_perms
# Error: /Stage[main]/Iptables::Rules::Mod_recent/Xt_recent[/sys/module/xt_recent/parameters]/ip_list_perms: change from '0640' to '0644' failed: Input/output error @ fptr_finalize_flush - /sys/module/xt_recent/parameters/ip_list_perms
pending 'https://github.com/simp/pupmod-simp-iptables/issues/129'
apply_manifest_on(host, manifest_with_scanblock_enabled, catch_failures: false)

# Reboot to ensure that the settings change takes effect
host.reboot

apply_manifest_on(host, manifest_with_scanblock_enabled, catch_failures: true)

on(host, "cat /etc/modprobe.d/xt_recent.conf", :acceptable_exit_codes => 0) do
expected = "options xt_recent ip_list_tot=400 ip_pkt_list_tot=40 ip_list_hash_size=256" +
Expand Down
Loading

0 comments on commit 23b4736

Please sign in to comment.