mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 16:28:43 -03:30
added id lookup
This commit is contained in:
@@ -21,7 +21,7 @@ description:
|
|||||||
options:
|
options:
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- The name of the project to update.
|
- The name or id of the project to update.
|
||||||
required: True
|
required: True
|
||||||
type: str
|
type: str
|
||||||
aliases:
|
aliases:
|
||||||
@@ -102,14 +102,19 @@ def main():
|
|||||||
interval = module.params.get('interval')
|
interval = module.params.get('interval')
|
||||||
timeout = module.params.get('timeout')
|
timeout = module.params.get('timeout')
|
||||||
|
|
||||||
# Attempt to look up project based on the provided name
|
# Attempt to look up project based on the provided name or id
|
||||||
lookup_data = {'name': name}
|
if name.isnumeric():
|
||||||
if organization:
|
results = module.get_endpoint('projects', **{'data': {'id': name}})
|
||||||
lookup_data['organization'] = module.resolve_name_to_id('organizations', organization)
|
project = results['json']['results'][0]
|
||||||
project = module.get_one('projects', data=lookup_data)
|
if project is None:
|
||||||
|
module.fail_json(msg="Unable to find project")
|
||||||
if project is None:
|
else:
|
||||||
module.fail_json(msg="Unable to find project")
|
lookup_data = {'name': name}
|
||||||
|
if organization:
|
||||||
|
lookup_data['organization'] = module.resolve_name_to_id('organizations', organization)
|
||||||
|
project = module.get_one('projects', data=lookup_data)
|
||||||
|
if project is None:
|
||||||
|
module.fail_json(msg="Unable to find project")
|
||||||
|
|
||||||
# Update the project
|
# Update the project
|
||||||
result = module.post_endpoint(project['related']['update'])
|
result = module.post_endpoint(project['related']['update'])
|
||||||
|
|||||||
Reference in New Issue
Block a user