From dbcdbe0770641d2e6e0083d42a020b045f6520d8 Mon Sep 17 00:00:00 2001 From: sean-m-ssullivan Date: Sun, 28 Mar 2021 22:35:38 -0500 Subject: [PATCH 1/4] add logic to changed status --- awx_collection/plugins/modules/tower_project_update.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/awx_collection/plugins/modules/tower_project_update.py b/awx_collection/plugins/modules/tower_project_update.py index 0ee764a5e4..42be06ea12 100644 --- a/awx_collection/plugins/modules/tower_project_update.py +++ b/awx_collection/plugins/modules/tower_project_update.py @@ -34,6 +34,7 @@ options: wait: description: - Wait for the project to update. + - If scm revision has not changed module will return not changed. default: True type: bool interval: @@ -109,6 +110,9 @@ def main(): if project is None: module.fail_json(msg="Unable to find project") + if wait: + scm_revision_original = project['scm_revision'] + # Update the project result = module.post_endpoint(project['related']['update']) @@ -126,7 +130,10 @@ def main(): start = time.time() # Invoke wait function - module.wait_on_url(url=result['json']['url'], object_name=module.get_item_name(project), object_type='Project Update', timeout=timeout, interval=interval) + result = module.wait_on_url(url=result['json']['url'], object_name=module.get_item_name(project), object_type='Project Update', timeout=timeout, interval=interval) + scm_revision_new = result['json']['scm_revision'] + if scm_revision_new == scm_revision_original: + module.json_output['changed'] = False module.exit_json(**module.json_output) From c2b5ffcc1c2c2bc69e8dcb2abfee6020b9e26d39 Mon Sep 17 00:00:00 2001 From: sean-m-ssullivan Date: Mon, 29 Mar 2021 00:21:29 -0500 Subject: [PATCH 2/4] linting --- awx_collection/plugins/modules/tower_project_update.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/awx_collection/plugins/modules/tower_project_update.py b/awx_collection/plugins/modules/tower_project_update.py index 42be06ea12..796f910df7 100644 --- a/awx_collection/plugins/modules/tower_project_update.py +++ b/awx_collection/plugins/modules/tower_project_update.py @@ -130,7 +130,9 @@ def main(): start = time.time() # Invoke wait function - result = module.wait_on_url(url=result['json']['url'], object_name=module.get_item_name(project), object_type='Project Update', timeout=timeout, interval=interval) + result = module.wait_on_url( + url=result['json']['url'], object_name=module.get_item_name(project), object_type='Project Update', timeout=timeout, interval=interval + ) scm_revision_new = result['json']['scm_revision'] if scm_revision_new == scm_revision_original: module.json_output['changed'] = False From fce544bb73d79f643dabb69352188edd5480f323 Mon Sep 17 00:00:00 2001 From: sean-m-ssullivan Date: Mon, 29 Mar 2021 22:14:06 -0500 Subject: [PATCH 3/4] add test logic --- .../integration/targets/tower_project_update/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/awx_collection/tests/integration/targets/tower_project_update/tasks/main.yml b/awx_collection/tests/integration/targets/tower_project_update/tasks/main.yml index 08b9852018..dd614d552a 100644 --- a/awx_collection/tests/integration/targets/tower_project_update/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_project_update/tasks/main.yml @@ -53,6 +53,7 @@ - assert: that: - result is successful + - result is not changed - name: Delete the test project 1 tower_project: From dde408ea1a275171fbb4098ddfa78af387314cfa Mon Sep 17 00:00:00 2001 From: sean-m-ssullivan Date: Tue, 30 Mar 2021 09:35:52 -0500 Subject: [PATCH 4/4] update docs --- awx_collection/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/awx_collection/README.md b/awx_collection/README.md index 61480a1b3d..506d00e4a3 100644 --- a/awx_collection/README.md +++ b/awx_collection/README.md @@ -72,6 +72,8 @@ Notable releases of the `awx.awx` collection: The following notes are changes that may require changes to playbooks: - When a project is created, it will wait for the update/sync to finish by default; this can be turned off with the `wait` parameter, if desired. + - When using the wait parameter with project update, if the project did not undergo a revision update, the result will be + 'not changed' - Creating a "scan" type job template is no longer supported. - Specifying a custom certificate via the `TOWER_CERTIFICATE` environment variable no longer works. - Type changes of variable fields: