From 712e79eb5e6eef58304ef424689378f4e42dc115 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 8 Apr 2019 14:49:35 +0200 Subject: [PATCH] ufw: fix default, direction is not necessary for it (#54799) * Correct behavior so that direction isn't required for default. * Add more tests. * 'disabled' values cannot be changed. * Include 'not specified' in messages. (cherry picked from commit 7d2734835640c9f10a1170b9152fa0db04dc6369) --- changelogs/fragments/54799-ufw-default-direction.yml | 2 ++ lib/ansible/modules/system/ufw.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/54799-ufw-default-direction.yml diff --git a/changelogs/fragments/54799-ufw-default-direction.yml b/changelogs/fragments/54799-ufw-default-direction.yml new file mode 100644 index 00000000000..5e46fc60d9c --- /dev/null +++ b/changelogs/fragments/54799-ufw-default-direction.yml @@ -0,0 +1,2 @@ +bugfixes: +- "ufw - when ``default`` is specified, ``direction`` does not needs to be specified. This was accidentally introduced in Ansible 2.7.8." diff --git a/lib/ansible/modules/system/ufw.py b/lib/ansible/modules/system/ufw.py index c80d6c37610..4a12bd18409 100644 --- a/lib/ansible/modules/system/ufw.py +++ b/lib/ansible/modules/system/ufw.py @@ -311,13 +311,13 @@ def main(): execute(cmd + [[command], [value]]) elif command == 'default': - if params['direction'] not in ['outgoing', 'incoming', 'routed']: - module.fail_json(msg='For default, direction must be one of "outgoing", "incoming" and "routed".') + if params['direction'] not in ['outgoing', 'incoming', 'routed', None]: + module.fail_json(msg='For default, direction must be one of "outgoing", "incoming" and "routed", or direction must not be specified.') execute(cmd + [[command], [value], [params['direction']]]) elif command == 'rule': if params['direction'] not in ['in', 'out', None]: - module.fail_json(msg='For rules, direction must be one of "in" and "out".') + module.fail_json(msg='For rules, direction must be one of "in" and "out", or direction must not be specified.') # Rules are constructed according to the long format # # ufw [--dry-run] [route] [delete] [insert NUM] allow|deny|reject|limit [in|out on INTERFACE] [log|log-all] \