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

Fixes #63254

Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
Adam Miller 2019-10-10 17:33:18 -05:00 committed by ansibot
parent bfd32c9b00
commit aaef214a26
4 changed files with 31 additions and 7 deletions

View file

@ -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)

View file

@ -8,7 +8,7 @@ from distutils.version import LooseVersion
FW_VERSION = None FW_VERSION = None
fw = None fw = None
fw_offline = None fw_offline = False
import_failure = True import_failure = True
try: try:
import firewall.config import firewall.config
@ -17,12 +17,12 @@ try:
from firewall.client import FirewallClient from firewall.client import FirewallClient
from firewall.client import FirewallClientZoneSettings from firewall.client import FirewallClientZoneSettings
from firewall.errors import FirewallError from firewall.errors import FirewallError
fw_offline = False
import_failure = False import_failure = False
try: try:
fw = FirewallClient() fw = FirewallClient()
fw.getDefaultZone() fw.getDefaultZone()
except (AttributeError, FirewallError): except (AttributeError, FirewallError):
# Firewalld is not currently running, permanent-only operations # Firewalld is not currently running, permanent-only operations
fw_offline = True fw_offline = True
@ -31,10 +31,15 @@ try:
# #
# NOTE: # NOTE:
# online and offline operations do not share a common firewalld API # online and offline operations do not share a common firewalld API
from firewall.core.fw_test import Firewall_test try:
fw = Firewall_test() from firewall.core.fw_test import Firewall_test
fw.start() 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: except ImportError:
pass pass

View file

@ -2,4 +2,3 @@ destructive
shippable/posix/group3 shippable/posix/group3
skip/freebsd skip/freebsd
skip/osx skip/osx
skip/rhel8.1b

View file

@ -29,8 +29,26 @@
register: check_output register: check_output
ignore_errors: true 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 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: when:
- not (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 7) - not (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 7)
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04") - not (ansible_distribution == "Ubuntu" and ansible_distribution_version == "14.04")