Closed jnm27 closed 3 years ago
Files identified in the description:
plugins/modules/vmware_guest.py
](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/vmware_guest.py)If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
cc @Akasurde @Tomorrow9 @goneri @lparkes @nerzhul @pdellaert @pgbidkar @warthog9 click here for bot help
@jnm27 Thanks for reporting this issue. There was a significant change in 1.8 release related to custom values and advanced settings - https://github.com/ansible-collections/community.vmware/pull/179.
Could you please confirm if you are using a standalone ESXi deployment?
As a workaround -
diff --git a/plugins/modules/vmware_guest.py b/plugins/modules/vmware_guest.py
index 6c5b755..6326d69 100644
--- a/plugins/modules/vmware_guest.py
+++ b/plugins/modules/vmware_guest.py
@@ -2210,6 +2210,9 @@ class PyVmomiHelper(PyVmomi):
if not self.params['customvalues']:
return
+ if not self.content.customFieldsManager:
+ return
+
facts = self.gather_facts(vm_obj)
for kv in self.params['customvalues']:
if 'key' not in kv or 'value' not in kv:
By standalone ESXi deployment, do you mean am I connecting directly to the ESXi host as opposed to vcenter? Yes.
By standalone ESXi deployment, do you mean am I connecting directly to the ESXi host as opposed to vcenter? Yes.
Yes,
customFieldManager is not available in a standalone ESXi. Can you please take a look at #179 and modify your playbook accordingly and let me know.
@Akasurde I tried using advanced_settings. It was successful, but it did not update the VMX file with the values I specified, neither on creation nor on reconfiguration.
Using customvalues on the base 2.9 version of vmware_guest does update the VMX file appropriately during creation.
Note that customvalues on the 1.8.0 version also does not create the VM with the correct VMX settings either.
@jnm27 Could you please provide the playbook used?
needs_info
With 2.9 vmware_guest customvalues: [root@ops03:/vmfs/volumes/6054c5e3-900d7846-faed-48df37da5d04/efd02] grep isolation efd02.vmx isolation.tools.unity.push.update.disable = "TRUE"
With 1.8.0 customvalues: [root@ops03:/vmfs/volumes/6054c5e3-900d7846-faed-48df37da5d04/efd02] grep isolation efd02.vmx [root@ops03:/vmfs/volumes/6054c5e3-900d7846-faed-48df37da5d04/efd02]
With 1.8.0 advanced_settings: [root@ops03:/vmfs/volumes/6054c5e3-900d7846-faed-48df37da5d04/efd02] grep isolation efd02.vmx [root@ops03:/vmfs/volumes/6054c5e3-900d7846-faed-48df37da5d04/efd02]
---> cat test_vmware_guest_no_values.yml
---
- hosts: localhost
tasks:
- name: Create the virtual machine on the ESXi host
community.vmware.vmware_guest:
#vmware_guest:
hostname: ops03
username: root
password: XXXX
validate_certs: no
folder: /ha-datacenter/vm
name: efd02
state: present
guest_id: rhel8_64Guest
disk:
- datastore: datastore1_ops03
size_gb: 100
type: thin
hardware:
boot_firmware: efi
memory_mb: 8192
num_cpu_cores_per_socket: 2
num_cpus: 2
scsi: paravirtual
#customvalues:
advanced_settings:
- key: "isolation.tools.unity.push.update.disable"
value: "TRUE"
@jnm27 I am unable to reproduce this issue with standalone ESXi and above playbook
---
- hosts: localhost
vars_files:
- vcenter_vars.yml
tasks:
- name: Create a Windows VM
vmware_guest:
validate_certs: False
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
folder: /ha-datacenter/vm
name: efd02
guest_id: "windows8_64Guest"
state: present
disk:
- size_mb: 512
type: thin
datastore: ds_200
hardware:
memory_mb: 4096
num_cpus: 2
scsi: lsilogicsas
advanced_settings:
- key: "isolation.tools.unity.push.update.disable"
value: "TRUE"
[root@dhcp201-106:/vmfs/volumes/5f8545e6-2dc76dd2-6833-52540034ab9f/efd02] grep isolation efd02
.vmx
isolation.tools.unity.push.update.disable = "TRUE"
Could you please upgrade to 1.9.0?
needs_info
SUMMARY
Able to create a new VM fine with vmware_guest, but when I run the same playbook again right after, it fails while "reconfiguring". I am using customvalues field, which is where it appears to be failing. This is using community version 1.8.0. If I step back to base Ansible 2.9 vmware_guest (no namespace), then it works fine. Although note that 2.9 vmware_guest always shows "changed" (it does not appear to be idempotent - please fix that also).
ISSUE TYPE
COMPONENT NAME
vmware_guest
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
RHEL8 VMware 7.0U1 community.vmware 1.8.0
STEPS TO REPRODUCE
EXPECTED RESULTS
The second run succeeds and does not show "changed".
ACTUAL RESULTS