mirror of
https://github.com/ansible/awx.git
synced 2026-02-01 09:38:10 -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:
@@ -50,7 +50,7 @@ options:
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
choices: ["present", "absent"]
|
||||
choices: ["present", "absent", "exists"]
|
||||
default: "present"
|
||||
type: str
|
||||
pull:
|
||||
@@ -83,7 +83,7 @@ def main():
|
||||
description=dict(),
|
||||
organization=dict(),
|
||||
credential=dict(),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
state=dict(choices=['present', 'absent', 'exists'], default='present'),
|
||||
# NOTE: Default for pull differs from API (which is blank by default)
|
||||
pull=dict(choices=['always', 'missing', 'never'], default='missing'),
|
||||
)
|
||||
@@ -99,7 +99,7 @@ def main():
|
||||
state = module.params.get('state')
|
||||
pull = module.params.get('pull')
|
||||
|
||||
existing_item = module.get_one('execution_environments', name_or_id=name)
|
||||
existing_item = module.get_one('execution_environments', name_or_id=name, check_exists=(state == 'exists'))
|
||||
|
||||
if state == 'absent':
|
||||
module.delete_if_needed(existing_item)
|
||||
|
||||
Reference in New Issue
Block a user