We use cloning to create new VMs in our vsphere cluster. The template is
usually powered on (to receive regular updates), so we power it off before
we create a clone:
- name: power off the template
vsphere_guest:
vcenter_hostname: "{{ vcenter }}"
username: "{{ user }}"
password: "{{ pass }}"
guest: "{{ template }}"
validate_certs: False
state: powered_off
force: yes
- debug: msg="template state is {{ hw_power_status }}."
- name: ensure the template is powered off
assert: { that: hw_power_status == "POWERED OFF" }
This used to work for VSphere 5.x, since the upgrade to VSphere 6.0 the
assert fails:
TASK [debug]
*******************************************************************
ok: [localhost] => {
"msg": "template state is POWERED ON."
}
TASK [ensure the template is powered off]
**************************************
fatal: [localhost]: FAILED! => {
"assertion": "hw_power_status == \"POWERED OFF\"",
"changed": false,
"evaluated_to": false,
"failed": true
}
VSphere shuts down the VM as requested, so maybe it is just a timing
problem?
So how can I ensure the VM is really powered off before the next task
starts? Is there a way to wait till hw_power_status changes?
Mathias
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/85453c75-9b2b-4f81-9bf1-ab2ae37234d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.