From 4de7de3ce9b92a546832edd8e8af97c20a4d2a0a Mon Sep 17 00:00:00 2001 From: John Westcott IV Date: Fri, 5 Jun 2020 13:29:37 -0400 Subject: [PATCH 1/3] Prevent exception for Non value --- awx_collection/plugins/modules/tower_settings.py | 4 ++++ .../tests/integration/targets/tower_settings/tasks/main.yml | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/awx_collection/plugins/modules/tower_settings.py b/awx_collection/plugins/modules/tower_settings.py index b7ecde45ef..a66acadf44 100644 --- a/awx_collection/plugins/modules/tower_settings.py +++ b/awx_collection/plugins/modules/tower_settings.py @@ -82,6 +82,10 @@ except ImportError: def coerce_type(module, value): + # If our value is already None we can just return directly + if value == None: + return value + yaml_ish = bool(( value.startswith('{') and value.endswith('}') ) or ( diff --git a/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml b/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml index a02ca673de..6cebe979e2 100644 --- a/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml @@ -74,3 +74,9 @@ - assert: that: - "result is changed" + +- name: Handle an omit value + tower_settings: + name: AWX_PROOT_BASE_PATH + value: '{{ junk_var | default(omit) }}' + From 95b8bd63ea005e45e15c6cb5fc8600d0ff9ec0c0 Mon Sep 17 00:00:00 2001 From: John Westcott IV Date: Mon, 8 Jun 2020 07:06:45 -0400 Subject: [PATCH 2/3] Fixing linting issues --- awx_collection/plugins/modules/tower_settings.py | 2 +- .../tests/integration/targets/tower_settings/tasks/main.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/awx_collection/plugins/modules/tower_settings.py b/awx_collection/plugins/modules/tower_settings.py index a66acadf44..ef4dcd9b1b 100644 --- a/awx_collection/plugins/modules/tower_settings.py +++ b/awx_collection/plugins/modules/tower_settings.py @@ -83,7 +83,7 @@ except ImportError: def coerce_type(module, value): # If our value is already None we can just return directly - if value == None: + if value is None: return value yaml_ish = bool(( diff --git a/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml b/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml index 6cebe979e2..16ee22e9e2 100644 --- a/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml @@ -79,4 +79,3 @@ tower_settings: name: AWX_PROOT_BASE_PATH value: '{{ junk_var | default(omit) }}' - From b457c8f1336c36cefa0c72fd1e413c2feec0be26 Mon Sep 17 00:00:00 2001 From: beeankha Date: Mon, 8 Jun 2020 09:57:16 -0400 Subject: [PATCH 3/3] Update a task in tower_settings integration test playbook --- .../tests/integration/targets/tower_settings/tasks/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml b/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml index 16ee22e9e2..8a42f5768e 100644 --- a/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_settings/tasks/main.yml @@ -79,3 +79,9 @@ tower_settings: name: AWX_PROOT_BASE_PATH value: '{{ junk_var | default(omit) }}' + register: result + ignore_errors: true + +- assert: + that: + - "'Unable to update settings' in result.msg"