community.vmware
community.vmware copied to clipboard
vmware.vmware_guest throws error when autologoncount parameter is not provided
SUMMARY
When using community.vmware.vmware_guest to deploy a machine from template and using customization it throws an error when not using autologoncount parameter (not marked as mandatory) Providing the parameter autologoncount resolves the issue.
ISSUE TYPE
- Bug Report
COMPONENT NAME
community.vmware.vmware_guest
ANSIBLE VERSION
ansible 2.10.6
config file = /usr/src/app/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.8/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.7 (default, Feb 19 2021, 01:11:05) [GCC 10.2.1 20201203]
CONFIGURATION
COLLECTIONS_PATHS(/usr/src/app/ansible.cfg) = ['/root/.ansible/collections', '/usr/share/ansible/collections']
DEFAULT_HOST_LIST(/usr/src/app/ansible.cfg) = ['/usr/src/app/hosts']
DEFAULT_JINJA2_NATIVE(/usr/src/app/ansible.cfg) = True
DEFAULT_LOG_PATH(/usr/src/app/ansible.cfg) = /usr/src/app/data/ansible.log
DEFAULT_ROLES_PATH(/usr/src/app/ansible.cfg) = ['/usr/src/app/roles']
OS / ENVIRONMENT
Alpine 3.13 Linux $hostname 4.15.0-1102-azure #113~16.04.1-Ubuntu SMP Wed Dec 9 20:42:32 UTC 2020 x86_64 Linux
STEPS TO REPRODUCE
- name: Clone VM from template
vmware_guest:
hostname: "{{ vmware.name }}"
username: "{{ vmware.username }}"
password: "{{ vmware.password }}"
datacenter: "{{ vmware_datacenter }}"
cluster: "{{ vmware_cluster }}"
name: "{{ server_name }}"
template: "{{ vmware_template }}"
state: poweredon
folder: "{{ vmware_folder }}"
hardware:
memory_mb: "{{ memory }}"
num_cpus: "{{ cpu }}"
disk:
- size_gb: "{{ disk0 }}"
datastore: "{{ vmware_datastore }}"
networks:
- name: "{{ port_group }}"
start_connected: True
type: dhcp
dvswitch_name: "{{ vmware_dvswitch }}"
customization:
hostname: "{{ server_name }}"
password: "{{ admin_password }}"
autologon: true
timezone: "{{ timezone }}"
runonce:
- powershell.exe
wait_for_ip_address: yes
wait_for_customization: true
EXPECTED RESULTS
VM is created from template
ACTUAL RESULTS
task path: /usr/src/app/roles/vmware_clone_template/tasks/main.yml:3
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154 `" && echo ansible-tmp-1614799013.9668589-447-9237018324154="` echo /root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154 `" ) && sleep 0'
redirecting (type: modules) ansible.builtin.vmware_guest to community.vmware.vmware_guest
Using module file /usr/lib/python3.8/site-packages/ansible_collections/community/vmware/plugins/modules/vmware_guest.py
<localhost> PUT /root/.ansible/tmp/ansible-local-308mx64zss_/tmp1_nn2f8_ TO /root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/AnsiballZ_vmware_guest.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/ /root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/AnsiballZ_vmware_guest.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/AnsiballZ_vmware_guest.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/AnsiballZ_vmware_guest.py", line 102, in <module>
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/AnsiballZ_vmware_guest.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/AnsiballZ_vmware_guest.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_guest', init_globals=None, run_name='__main__', alter_sys=True)
File "/usr/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/ansible_vmware_guest_payload_j0pwuq_5/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py", line 3511, in <module>
File "/tmp/ansible_vmware_guest_payload_j0pwuq_5/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py", line 3500, in main
File "/tmp/ansible_vmware_guest_payload_j0pwuq_5/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py", line 2983, in deploy_vm
File "/tmp/ansible_vmware_guest_payload_j0pwuq_5/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py", line 2294, in customize_vm
File "/usr/lib/python3.8/site-packages/pyVmomi/VmomiSupport.py", line 663, in __setattr__
CheckField(self._GetPropertyInfo(name), val)
File "/usr/lib/python3.8/site-packages/pyVmomi/VmomiSupport.py", line 1041, in CheckField
raise TypeError('Required field "%s" not provided (not @optional)' % info.name)
TypeError: Required field "autoLogonCount" not provided (not @optional)
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/AnsiballZ_vmware_guest.py\", line 102, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/AnsiballZ_vmware_guest.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1614799013.9668589-447-9237018324154/AnsiballZ_vmware_guest.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_guest', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_vmware_guest_payload_j0pwuq_5/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py\", line 3511, in <module>\n File \"/tmp/ansible_vmware_guest_payload_j0pwuq_5/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py\", line 3500, in main\n File \"/tmp/ansible_vmware_guest_payload_j0pwuq_5/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py\", line 2983, in deploy_vm\n File \"/tmp/ansible_vmware_guest_payload_j0pwuq_5/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py\", line 2294, in customize_vm\n File \"/usr/lib/python3.8/site-packages/pyVmomi/VmomiSupport.py\", line 663, in __setattr__\n CheckField(self._GetPropertyInfo(name), val)\n File \"/usr/lib/python3.8/site-packages/pyVmomi/VmomiSupport.py\", line 1041, in CheckField\n raise TypeError('Required field \"%s\" not provided (not @optional)' % info.name)\nTypeError: Required field \"autoLogonCount\" not provided (not @optional)\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
Files identified in the description: None
If these files are inaccurate, please update the component name section of the description or use the !component bot command.
@mariolenz This looks like it's related to recent work that you did. Would you mind taking a look at this?
Hello, I am having the same issue.
Python 3.9.7 ansible [core 2.13.2]
task path: /home/ansible/tasks/create_sql_vm.yml:18
echo /home/ansible/.ansible/tmp"&& mkdir "echo /home/ansible/.ansible/tmp/ansible-tmp-1659787809.3364856-220498-145561652743209" && echo ansible-tmp-1659787809.3364856-220498-145561652743209="echo /home/ansible/.ansible/tmp/ansible-tmp-1659787809.3364856-220498-145561652743209" ) && sleep 0'
Using module file /usr/local/lib/python3.9/site-packages/ansible_collections/community/vmware/plugins/modules/vmware_guest.py
Note to myself:
https://github.com/ansible-collections/community.vmware/blob/52641b96fd9b74d5a5826b17262753efee4eb640/plugins/modules/vmware_guest.py#L636-L642
and
https://github.com/ansible-collections/community.vmware/blob/52641b96fd9b74d5a5826b17262753efee4eb640/plugins/modules/vmware_guest.py#L2206-L2208
@jeffreyaweaver What version of this collection are you running? ansible-galaxy collection list community.vmware should tell you.
This was installed fresh box today.
/usr/local/lib/python3.9/site-packages/ansible_collections Collection Version
community.vmware 2.7.0
I have the same issue when the parameter is not provided, plus it also throws an error when you include the autologoncount parameter. My setup: new clean vm python 3.8.12 ansible [core 2.13.3] collection version: community.vmware 2.8.0
- name: Create Windows VM from template
vmware_guest:
hostname: "{{ vsphere.host }}"
username: "{{ vcenter_credentials.username }}"
password: "{{ vcenter_credentials.password }}"
validate_certs: false
datacenter: "{{ template_data.datacenter }}"
datastore: "{{ template_data.clone_datastore }}"
state: poweredon
folder: "{{ template_data.vm_folder }}"
template: "{{ template_name }}"
name: "{{ inventory_hostname_short }}"
cluster: "{{ template_data.cluster }}"
hardware:
memory_mb: "{{ template_data.ram_mb }}"
num_cpus: "{{ template_data.cpu_cores }}"
networks:
- ip: "{{ ipam_ip }}"
name: "{{ template_data.vs_net_name }}"
netmask: "{{ ipam_nm }}"
gateway: "{{ ipam_gw }}"
domain: "{{ template_data.domain }}"
dns_servers: "{{ template_data.dns_servers }}"
type: static
start_connected: true
customization:
autologon: true
autologoncount: 1
dns_servers: "{{ template_data.dns_servers }}"
joindomain: "{{ template_data.domain }}"
domainadmin: "{{ domainadmin.username }}@{{ template_data.domain }}"
domainadminpassword: "{{ domainadmin.password }}"
domain: "{{ template_data.domain }}"
password: "{{ windows_local_credentials.password }}"
timezone: 35
hostname: "{{ inventory_hostname_short }}"
wait_for_ip_address: true
wait_for_customization: true
delegate_to: localhost
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: Required field "autoLogonCount" not provided (not @optional)
fatal: [s2p2-daily-win -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/tmp/.ansible-xbbldkx/tmp/ansible-tmp-1661361448.2286444-1201612-122927393420146/AnsiballZ_vmware_guest.py", line 107, in
do you solved it @davebuchholz-bny ?
I have the same issue when the parameter is not provided, plus it also throws an error when you include the autologoncount parameter. My setup: new clean vm python 3.8.12 ansible [core 2.13.3] collection version: community.vmware 2.8.0
- name: Create Windows VM from template vmware_guest: hostname: "{{ vsphere.host }}" username: "{{ vcenter_credentials.username }}" password: "{{ vcenter_credentials.password }}" validate_certs: false datacenter: "{{ template_data.datacenter }}" datastore: "{{ template_data.clone_datastore }}" state: poweredon folder: "{{ template_data.vm_folder }}" template: "{{ template_name }}" name: "{{ inventory_hostname_short }}" cluster: "{{ template_data.cluster }}" hardware: memory_mb: "{{ template_data.ram_mb }}" num_cpus: "{{ template_data.cpu_cores }}" networks: - ip: "{{ ipam_ip }}" name: "{{ template_data.vs_net_name }}" netmask: "{{ ipam_nm }}" gateway: "{{ ipam_gw }}" domain: "{{ template_data.domain }}" dns_servers: "{{ template_data.dns_servers }}" type: static start_connected: true customization: autologon: true autologoncount: 1 dns_servers: "{{ template_data.dns_servers }}" joindomain: "{{ template_data.domain }}" domainadmin: "{{ domainadmin.username }}@{{ template_data.domain }}" domainadminpassword: "{{ domainadmin.password }}" domain: "{{ template_data.domain }}" password: "{{ windows_local_credentials.password }}" timezone: 35 hostname: "{{ inventory_hostname_short }}" wait_for_ip_address: true wait_for_customization: true delegate_to: localhostAn exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: Required field "autoLogonCount" not provided (not @optional) fatal: [s2p2-daily-win -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/tmp/.ansible-xbbldkx/tmp/ansible-tmp-1661361448.2286444-1201612-122927393420146/AnsiballZ_vmware_guest.py", line 107, in \n _ansiballz_main()\n File "/tmp/.ansible-xbbldkx/tmp/ansible-tmp-1661361448.2286444-1201612-122927393420146/AnsiballZ_vmware_guest.py", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/tmp/.ansible-xbbldkx/tmp/ansible-tmp-1661361448.2286444-1201612-122927393420146/AnsiballZ_vmware_guest.py", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.vmware.plugins.modules.vmware_guest', init_globals=dict(_module_fqn='ansible_collections.community.vmware.plugins.modules.vmware_guest', _modlib_path=modlib_path),\n File "/usr/lib64/python3.8/runpy.py", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib64/python3.8/runpy.py", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_vmware_guest_payload_alnk0n89/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py", line 3461, in \n File "/tmp/ansible_vmware_guest_payload_alnk0n89/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py", line 3450, in main\n File "/tmp/ansible_vmware_guest_payload_alnk0n89/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py", line 2888, in deploy_vm\n File "/tmp/ansible_vmware_guest_payload_alnk0n89/ansible_vmware_guest_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_guest.py", line 2209, in customize_vm\n File "/pghhome/invsyshome/xbbldkx/dev/venvs/ansible-test/lib64/python3.8/site-packages/pyVmomi/VmomiSupport.py", line 663, in setattr\n CheckField(self._GetPropertyInfo(name), val)\n File "/pghhome/invsyshome/xbbldkx/dev/venvs/ansible-test/lib64/python3.8/site-packages/pyVmomi/VmomiSupport.py", line 1041, in CheckField\n raise TypeError('Required field "%s" not provided (not @optional)' % info.name)\nTypeError: Required field "autoLogonCount" not provided (not @optional)\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}