Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapt to firewalld 0.7.0 for RHEL 8.1 Beta, Fedora 31+ #63357

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/firewalld-version-0_7_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- firewalld - enable the firewalld module to function offline with firewalld version 0.7.0 and newer (https://github.com/ansible/ansible/issues/63254)
15 changes: 10 additions & 5 deletions lib/ansible/module_utils/firewalld.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

FW_VERSION = None
fw = None
fw_offline = None
fw_offline = False
import_failure = True
try:
import firewall.config
Expand All @@ -17,12 +17,12 @@
from firewall.client import FirewallClient
from firewall.client import FirewallClientZoneSettings
from firewall.errors import FirewallError
fw_offline = False
import_failure = False

try:
fw = FirewallClient()
fw.getDefaultZone()

except (AttributeError, FirewallError):
# Firewalld is not currently running, permanent-only operations
fw_offline = True
Expand All @@ -31,10 +31,15 @@
#
# NOTE:
# online and offline operations do not share a common firewalld API
from firewall.core.fw_test import Firewall_test
fw = Firewall_test()
fw.start()
try:
from firewall.core.fw_test import Firewall_test
fw = Firewall_test()
except (ModuleNotFoundError):
# In firewalld version 0.7.0 this behavior changed
from firewall.core.fw import Firewall
fw = Firewall(offline=True)

fw.start()
except ImportError:
pass

Expand Down
1 change: 0 additions & 1 deletion test/integration/targets/firewalld/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ destructive
shippable/posix/group3
skip/freebsd
skip/osx
skip/rhel8.1b
20 changes: 19 additions & 1 deletion test/integration/targets/firewalld/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,26 @@
register: check_output
ignore_errors: true

- import_tasks: run_all_tests.yml
- name: Test Online Operations
block:
- name: start firewalld
service:
name: firewalld
state: started

- import_tasks: run_all_tests.yml
when: check_output.rc == 0

- name: Test Offline Operations
block:
- name: stop firewalld
service:
name: firewalld
state: stopped

- import_tasks: run_all_tests.yml
when: check_output.rc == 0

when:
- not (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 7)
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04")
Expand Down