ovirt_vms: Fix the module to work with check mode (#37916)
Fixes: https://github.com/ansible/ansible/issues/36712
This commit is contained in:
parent
0a17adb3df
commit
17928ff666
2 changed files with 22 additions and 18 deletions
|
@ -581,6 +581,7 @@ class BaseModule(object):
|
||||||
self.post_create(entity)
|
self.post_create(entity)
|
||||||
self.changed = True
|
self.changed = True
|
||||||
|
|
||||||
|
if not self._module.check_mode:
|
||||||
# Wait for the entity to be created and to be in the defined state:
|
# Wait for the entity to be created and to be in the defined state:
|
||||||
entity_service = self._service.service(entity.id)
|
entity_service = self._service.service(entity.id)
|
||||||
|
|
||||||
|
@ -603,7 +604,7 @@ class BaseModule(object):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'changed': self.changed,
|
'changed': self.changed,
|
||||||
'id': entity.id,
|
'id': getattr(entity, 'id', None),
|
||||||
type(entity).__name__.lower(): get_dict_of_struct(
|
type(entity).__name__.lower(): get_dict_of_struct(
|
||||||
struct=entity,
|
struct=entity,
|
||||||
connection=self._connection,
|
connection=self._connection,
|
||||||
|
|
|
@ -1933,8 +1933,11 @@ def main():
|
||||||
clone=module.params['clone'],
|
clone=module.params['clone'],
|
||||||
clone_permissions=module.params['clone_permissions'],
|
clone_permissions=module.params['clone_permissions'],
|
||||||
)
|
)
|
||||||
vms_module.post_present(ret['id'])
|
# If VM is going to be created and check_mode is on, return now:
|
||||||
|
if module.check_mode and ret.get('id') is None:
|
||||||
|
module.exit_json(**ret)
|
||||||
|
|
||||||
|
vms_module.post_present(ret['id'])
|
||||||
# Run the VM if it was just created, else don't run it:
|
# Run the VM if it was just created, else don't run it:
|
||||||
if state == 'running':
|
if state == 'running':
|
||||||
initialization = vms_module.get_initialization()
|
initialization = vms_module.get_initialization()
|
||||||
|
|
Loading…
Add table
Reference in a new issue