Add support for firewalld on Ubuntu

Enables the installation and configuration of firewalld on Ubuntu
systems.

Change-Id: I4a97a2aeed277be672e15e5c7727b810e11d3c42
Story: 2010160
Task: 45818
This commit is contained in:
k-s-dean 2022-07-19 16:40:35 +01:00
parent 17d49908af
commit 6990a041c7
10 changed files with 14 additions and 20 deletions

View File

@ -5,8 +5,7 @@
- config - config
- firewall - firewall
tasks: tasks:
- name: Configure the firewall - name: Configure firewalld
include_role: include_role:
name: "firewall-{{ ansible_facts.os_family | lower }}" name: "firewalld"
when:
- ansible_facts.os_family == 'RedHat'

View File

@ -469,12 +469,11 @@ Firewalld
*tags:* *tags:*
| ``firewall`` | ``firewall``
.. note:: Firewalld is supported on CentOS and Rocky systems only. Currently no Firewalld can be used to provide a firewall on supported systems. Since the
firewall is supported on Ubuntu.
Firewalld can be used to provide a firewall on CentOS/Rocky systems. Since the
Xena release, Kayobe provides support for enabling or disabling firewalld, as Xena release, Kayobe provides support for enabling or disabling firewalld, as
well as defining zones and rules. well as defining zones and rules.
Since the Zed 13.0.0 release, Kayobe added support for configuring firewalld on
Ubuntu systems.
The following variables can be used to set whether to enable firewalld: The following variables can be used to set whether to enable firewalld:

View File

@ -170,7 +170,7 @@ chrony_ntp_servers:
- option: maxsources - option: maxsources
val: 2 val: 2
# Enable firewalld (CentOS only). # Enable firewalld
controller_firewalld_enabled: true controller_firewalld_enabled: true
controller_firewalld_zones: controller_firewalld_zones:
- zone: test-zone1 - zone: test-zone1

View File

@ -11,11 +11,6 @@ import distro
import pytest import pytest
def _is_firewalld_supported():
info = distro.id()
return info in ['centos', 'rocky']
def _is_apt(): def _is_apt():
info = distro.linux_distribution() info = distro.linux_distribution()
return info[0].startswith('Ubuntu') return info[0].startswith('Ubuntu')
@ -25,10 +20,12 @@ def _is_dnf():
info = distro.id() info = distro.id()
return info in ['centos', 'rocky'] return info in ['centos', 'rocky']
def _is_dnf_mirror(): def _is_dnf_mirror():
info = distro.id() info = distro.id()
return info == 'centos' return info == 'centos'
def test_network_ethernet(host): def test_network_ethernet(host):
interface = host.interface('dummy2') interface = host.interface('dummy2')
assert interface.exists assert interface.exists
@ -241,16 +238,12 @@ def test_tuned_profile_is_active(host):
assert "throughput-performance" in tuned_output assert "throughput-performance" in tuned_output
@pytest.mark.skipif(not _is_firewalld_supported(),
reason="Firewalld only supported on CentOS and Rocky")
def test_firewalld_running(host): def test_firewalld_running(host):
assert host.package("firewalld").is_installed assert host.package("firewalld").is_installed
assert host.service("firewalld.service").is_enabled assert host.service("firewalld.service").is_enabled
assert host.service("firewalld.service").is_running assert host.service("firewalld.service").is_running
@pytest.mark.skipif(not _is_firewalld_supported(),
reason="Firewalld only supported on CentOS and Rocky")
def test_firewalld_zones(host): def test_firewalld_zones(host):
# Verify that interfaces are on correct zones. # Verify that interfaces are on correct zones.
expected_zones = { expected_zones = {
@ -272,8 +265,6 @@ def test_firewalld_zones(host):
assert zone == expected_zone assert zone == expected_zone
@pytest.mark.skipif(not _is_firewalld_supported(),
reason="Firewalld only supported on CentOS and Rocky")
def test_firewalld_rules(host): def test_firewalld_rules(host):
# Verify that expected rules are present. # Verify that expected rules are present.
expected_info = { expected_info = {

View File

@ -0,0 +1,5 @@
---
features:
- |
Adds support for configuring a firewall via firewalld on Ubuntu. See `story
2010160 <https://storyboard.openstack.org/#!/story/2010160>`__ for details.