Skip to content

Commit

Permalink
VMware: Gather facts when powerstate is specified (ansible#37908)
Browse files Browse the repository at this point in the history
This fix adds additional facts after VM powerstate management.

Signed-off-by: Abhijeet Kasurde <[email protected]>
  • Loading branch information
Akasurde authored Mar 27, 2018
1 parent 6e737c8 commit 4edcbeb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/ansible/module_utils/vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,7 @@ def set_vm_power_state(content, vm, state, force, timeout=0):
result['changed'] = True

# need to get new metadata if changed
if result['changed']:
result['instance'] = gather_vm_facts(content, vm)
result['instance'] = gather_vm_facts(content, vm)

return result

Expand Down
1 change: 1 addition & 0 deletions lib/ansible/modules/cloud/vmware/vmware_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,7 @@ def main():
result["changed"] = True
if not tmp_result["failed"]:
result["failed"] = False
result['instance'] = tmp_result['instance']
else:
# This should not happen
raise AssertionError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
that:
- "clone_d1_c1_f0_recreate.results|map(attribute='changed')|unique|list == [false]"

- name: assert that no changes were made after re-creating VM and task returns facts
assert:
that:
- "'newvm_' + item | basename in clone_d1_c1_f0.results|map(attribute='instance.hw_name')|list"
with_items: "{{ vmlist['json'] }}"

- name: modify the new VMs
vmware_guest:
validate_certs: False
Expand Down

0 comments on commit 4edcbeb

Please sign in to comment.