Merge pull request #5343 from beeankha/wait_for_project_sync

Make tower_project.py Wait for Project Sync

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-11-20 15:22:56 +00:00 committed by GitHub
commit 19742859b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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:

View File

@ -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