diff --git a/awx_collection/README.md b/awx_collection/README.md index 2340ed4336..901ac06b49 100644 --- a/awx_collection/README.md +++ b/awx_collection/README.md @@ -18,6 +18,7 @@ The following notes are changes that may require changes to playbooks. - Specifying `inputs` or `injectors` as strings in the `tower_credential_type` module is no longer supported. Provide as dictionaries instead. + - 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. ## Running diff --git a/awx_collection/plugins/modules/tower_project.py b/awx_collection/plugins/modules/tower_project.py index 5c5f90faaa..4c80b64889 100644 --- a/awx_collection/plugins/modules/tower_project.py +++ b/awx_collection/plugins/modules/tower_project.py @@ -97,6 +97,15 @@ options: default: "present" choices: ["present", "absent"] type: str + wait: + description: + - Provides option (True by default) to wait for completed project sync + before returning + - Can assure playbook files are populated so that job templates that rely + on the project may be successfully created + + type: bool + default: True extends_documentation_fragment: awx.awx.auth ''' @@ -150,6 +159,7 @@ def main(): custom_virtualenv=dict(), local_path=dict(), state=dict(choices=['present', 'absent'], default='present'), + wait=dict(type='bool', default=True), ) module = TowerModule(argument_spec=argument_spec, supports_check_mode=True) @@ -171,6 +181,7 @@ def main(): job_timeout = module.params.get('job_timeout') custom_virtualenv = module.params.get('custom_virtualenv') state = module.params.get('state') + wait = module.params.get('wait') json_output = {'project': name, 'state': state} @@ -212,6 +223,8 @@ def main(): custom_virtualenv=custom_virtualenv, create_on_missing=True) json_output['id'] = result['id'] + if wait: + project.wait(pk=None, parent_pk=result['id']) elif state == 'absent': result = project.delete(name=name) except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo: diff --git a/awx_collection/test/awx/test_project.py b/awx_collection/test/awx/test_project.py index fa749cd6e0..3c858f5a04 100644 --- a/awx_collection/test/awx/test_project.py +++ b/awx_collection/test/awx/test_project.py @@ -12,7 +12,8 @@ def test_create_project(run_module, admin_user, organization): name='foo', organization=organization.name, scm_type='git', - scm_url='https://foo.invalid' + scm_url='https://foo.invalid', + wait=False ), admin_user) assert result.pop('changed', None), result