mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
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:
@@ -18,6 +18,7 @@ The following notes are changes that may require changes to playbooks.
|
|||||||
|
|
||||||
- Specifying `inputs` or `injectors` as strings in the
|
- Specifying `inputs` or `injectors` as strings in the
|
||||||
`tower_credential_type` module is no longer supported. Provide as dictionaries instead.
|
`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
|
## Running
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,15 @@ options:
|
|||||||
default: "present"
|
default: "present"
|
||||||
choices: ["present", "absent"]
|
choices: ["present", "absent"]
|
||||||
type: str
|
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
|
extends_documentation_fragment: awx.awx.auth
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@@ -150,6 +159,7 @@ def main():
|
|||||||
custom_virtualenv=dict(),
|
custom_virtualenv=dict(),
|
||||||
local_path=dict(),
|
local_path=dict(),
|
||||||
state=dict(choices=['present', 'absent'], default='present'),
|
state=dict(choices=['present', 'absent'], default='present'),
|
||||||
|
wait=dict(type='bool', default=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
module = TowerModule(argument_spec=argument_spec, supports_check_mode=True)
|
module = TowerModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||||
@@ -171,6 +181,7 @@ def main():
|
|||||||
job_timeout = module.params.get('job_timeout')
|
job_timeout = module.params.get('job_timeout')
|
||||||
custom_virtualenv = module.params.get('custom_virtualenv')
|
custom_virtualenv = module.params.get('custom_virtualenv')
|
||||||
state = module.params.get('state')
|
state = module.params.get('state')
|
||||||
|
wait = module.params.get('wait')
|
||||||
|
|
||||||
json_output = {'project': name, 'state': state}
|
json_output = {'project': name, 'state': state}
|
||||||
|
|
||||||
@@ -212,6 +223,8 @@ def main():
|
|||||||
custom_virtualenv=custom_virtualenv,
|
custom_virtualenv=custom_virtualenv,
|
||||||
create_on_missing=True)
|
create_on_missing=True)
|
||||||
json_output['id'] = result['id']
|
json_output['id'] = result['id']
|
||||||
|
if wait:
|
||||||
|
project.wait(pk=None, parent_pk=result['id'])
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
result = project.delete(name=name)
|
result = project.delete(name=name)
|
||||||
except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
|
except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ def test_create_project(run_module, admin_user, organization):
|
|||||||
name='foo',
|
name='foo',
|
||||||
organization=organization.name,
|
organization=organization.name,
|
||||||
scm_type='git',
|
scm_type='git',
|
||||||
scm_url='https://foo.invalid'
|
scm_url='https://foo.invalid',
|
||||||
|
wait=False
|
||||||
), admin_user)
|
), admin_user)
|
||||||
assert result.pop('changed', None), result
|
assert result.pop('changed', None), result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user