Skip to content

Commit

Permalink
Make second group match of ufw status output optional (#56678)
Browse files Browse the repository at this point in the history
* Make second group match of ufw status output optional

Fixes #56674

* Fix comparison logic.

* Add changelog fragment

(cherry picked from commit 1d22909)
  • Loading branch information
tyleha authored and abadger committed May 28, 2019
1 parent 7d9aa0d commit 0128006
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/56678-ufw-status-change-detection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ufw - correctly check status when logging is off (https://github.com/ansible/ansible/issues/56674)
6 changes: 4 additions & 2 deletions lib/ansible/modules/system/ufw.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,14 @@ def ufw_version():
execute(cmd + [['-f'], [states[value]]])

elif command == 'logging':
extract = re.search(r'Logging: (on|off) \(([a-z]+)\)', pre_state)
extract = re.search(r'Logging: (on|off)(?: \(([a-z]+)\))?', pre_state)
if extract:
current_level = extract.group(2)
current_on_off_value = extract.group(1)
if value != "off":
if value != "on" and (value != current_level or current_on_off_value == "off"):
if current_on_off_value == "off":
changed = True
elif value != "on" and value != current_level:
changed = True
elif current_on_off_value != "off":
changed = True
Expand Down

0 comments on commit 0128006

Please sign in to comment.