Skip to content

vmware_tools pyVmomi.VmomiSupport.vim.fault.InvalidState: (vim.fault.InvalidState) 'The operation is not allowed in the current state.' #917

Open
@a-stoyanov

Description

@a-stoyanov
SUMMARY

Executing a task using ansible.windows.win_updates module over a vmware_tools connection results in a failure.
Note: I have seen test runs of the same task complete a few times, however during my testing there's been over 90% failure with same error code running on different test VMs.
Running the same task over a winrm connection completes without issues.
There seems to be some sort of bug in the iterraction of win_updates, vmware_tools and pyvmomi.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

plugins/connection/vmware_tools.py
plugins/action/win_updates.py

ANSIBLE VERSION
ansible 2.9.23
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Mar 19 2021, 05:13:41) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
COLLECTION VERSION
 "collection_info": {
  "namespace": "community",
  "name": "vmware",
  "version": "1.11.0",
  "authors": [
...
 "collection_info": {
  "namespace": "ansible",
  "name": "windows",
  "version": "1.7.0",
...
CONFIGURATION

n/a

OS / ENVIRONMENT

Ansible node
Linux 4.18.0-305.3.1.el8.x86_64 #1 SMP
Python 3.6.8

Name: pyvmomi
Version: 7.0.2

Name: vSphere-Automation-SDK
Version: 1.44.0

Test host
Win Server 2019
vSphere 6.7

STEPS TO REPRODUCE
- name: "[{{ inventory_hostname }}] Install all available Windows Updates (exclude Drivers category)"
   win_updates:
     server_selection: windows_update
     category_names:
       - SecurityUpdates
       - CriticalUpdates
       - UpdateRollups
       - Updates
       - DefinitionUpdates
       - FeaturePacks
     state: installed
     reboot: yes
     reboot_timeout: 3600
     log_path: c:\ansible_wu.txt
   register: vm_win_updates_installed
EXPECTED RESULTS

Task completes without errors

ACTUAL RESULTS
win_updates: running win_updates module
Using module file /usr/lib/python3.6/site-packages/ansible/modules/windows/win_updates.ps1
The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 665, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/action/win_updates.py", line 224, in run
    use_task)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/action/win_updates.py", line 28, in _run_win_updates
    use_task=use_task)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/action/win_updates.py", line 117, in _execute_module_with_become
    wrap_async=wrap_async)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 933, in _execute_module
    res = self._low_level_execute_command(cmd, sudoable=sudoable, in_data=in_data)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 1085, in _low_level_execute_command
    rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/vmware_tools.py", line 456, in exec_command
    pid_info = self._get_pid_info(pid)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/vmware_tools.py", line 398, in _get_pid_info
    processes = self.processManager.ListProcessesInGuest(vm=self.vm, auth=self.vm_auth, pids=[pid])
  File "/usr/local/lib/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 706, in <lambda>
    self.f(*(self.args + (obj,) + args), **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 512, in _InvokeMethod
    return self._stub.InvokeMethod(self, info, args)
  File "/usr/local/lib/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 1397, in InvokeMethod
    raise obj # pylint: disable-msg=E0702
pyVmomi.VmomiSupport.vim.fault.InvalidState: (vim.fault.InvalidState) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = 'The operation is not allowed in the current state.',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) []
}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 147, in run
    res = self._execute()
  File "/usr/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 673, in _execute
    self._handler.cleanup()
  File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 128, in cleanup
    self._remove_tmp_path(self._connection._shell.tmpdir)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 417, in _remove_tmp_path
    tmp_rm_res = self._low_level_execute_command(cmd, sudoable=False)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/action/__init__.py", line 1085, in _low_level_execute_command
    rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/vmware_tools.py", line 440, in exec_command
    stdout = self.create_temporary_file_in_guest(suffix=".stdout")
  File "/usr/lib/python3.6/site-packages/ansible/plugins/connection/vmware_tools.py", line 365, in create_temporary_file_in_guest
    return self.fileManager.CreateTemporaryFileInGuest(vm=self.vm, auth=self.vm_auth, prefix=prefix, suffix=suffix)
  File "/usr/local/lib/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 706, in <lambda>
    self.f(*(self.args + (obj,) + args), **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 512, in _InvokeMethod
    return self._stub.InvokeMethod(self, info, args)
  File "/usr/local/lib/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 1397, in InvokeMethod
    raise obj # pylint: disable-msg=E0702
pyVmomi.VmomiSupport.vim.fault.InvalidState: (vim.fault.InvalidState) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = 'The operation is not allowed in the current state.',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) []
}
fatal: [test-host01]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugcloudconnectionconnection pluginneeds_triageNeeds a first human triage before being processed.pluginsplugin (any type)python3traceback

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions