mirror of
https://github.com/ansible/awx.git
synced 2026-02-12 07:04:45 -03:30
Make state exists universal in collection (#13890)
Make state: exists available for all API modules Make state:exists return the ID just like it would if it created the resource
This commit is contained in:
@@ -247,7 +247,7 @@ def main():
|
||||
if organization:
|
||||
lookup_data['organization'] = org_id
|
||||
|
||||
credential = module.get_one('credentials', name_or_id=name, **{'data': lookup_data})
|
||||
credential = module.get_one('credentials', name_or_id=name, check_exists=(state == 'exists'), **{'data': lookup_data})
|
||||
|
||||
# Attempt to look up credential to copy based on the provided name
|
||||
if copy_from:
|
||||
@@ -265,10 +265,6 @@ def main():
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
module.delete_if_needed(credential)
|
||||
|
||||
if state == 'exists' and credential is not None:
|
||||
# If credential exists and state is exists, we're done here.
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
# Attempt to look up the related items the user specified (these will fail the module if not found)
|
||||
if user:
|
||||
user_id = module.resolve_name_to_id('users', user)
|
||||
|
||||
Reference in New Issue
Block a user