ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
348 stars 334 forks source link

Windows modules run as async via vmware_tools connection plugin attempt to find python interpreter #1264

Open mgaruccio opened 2 years ago

mgaruccio commented 2 years ago
SUMMARY

When running a windows module with async ansible attempts to find a python interpreter on the host, which fails.

ISSUE TYPE
COMPONENT NAME

vmware_tools connection plugin

ANSIBLE VERSION
ansible [core 2.12.3]
  config file = /Users/michaelgaruccio/code/EEW-Deploy/ansible.cfg
  configured module search path = ['/Users/michaelgaruccio/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/michaelgaruccio/.local/share/virtualenvs/EEW-Deploy-XQOoyyKX/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/michaelgaruccio/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/michaelgaruccio/.local/share/virtualenvs/EEW-Deploy-XQOoyyKX/bin/ansible
  python version = 3.9.7 (default, Nov  5 2021, 16:21:26) [Clang 13.0.0 (clang-1300.0.29.3)]
  jinja version = 3.1.0
  libyaml = True
COLLECTION VERSION
# /Users/michaelgaruccio/.local/share/virtualenvs/EEW-Deploy-XQOoyyKX/lib/python3.9/site-packages/ansible_collections
Collection       Version
---------------- -------
community.vmware 1.17.1

# /Users/michaelgaruccio/.ansible/collections/ansible_collections
Collection       Version
---------------- -------
community.vmware 2.1.0
CONFIGURATION
OS / ENVIRONMENT

Ansible control machine is apple silicon mac using python 3.9.7

STEPS TO REPRODUCE

Run a playbook that uses the vmware_tools connection plugin with any windows module using the async option

- name: add to inventory
  hosts: localhost
  gather_facts: no
  tasks:
  - name: add host to inventory
    add_host:
      hostname: EEC-DC01
      ansible_vmware_guest_path: "ACM/vm/EEW_deploy/EEC-DC01"

- name: configure domain controller
  hosts: all
  gather_facts: no
  connection: community.vmware.vmware_tools
  vars:
    ansible_shell_type: powershell
    ansible_vmware_host: "{{ vcenter_hostname }}"
    ansible_vmware_user: "{{ vcenter_username }}"
    ansible_user: "{{ vm_username }}"
    ansible_password: "{{ vm_password }}"
    ansible_vmware_password: "{{ vcenter_password }}"
    ansible_vmware_validate_certs: no
    ansible_vmware_tools_user: "{{ vm_username }}"
    ansible_vmware_tools_password: "{{ vm_password }}"

  tasks:
  - name: start print spooler
    ansible.windows.win_service:
      name: spooler
      state: started
    async: 600
    poll: 0
    register: service_sleeper
EXPECTED RESULTS

Expect the task to kick off successfully

ACTUAL RESULTS

The playbook attempts to find a python interpreter, which fails due to targeting a windows host, and then crashes

PLAY [configure domain controller] *******************************************************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [start print spooler] ***************************************************************************************************************************************************************************************************************************************************************************
task path: /Users/michaelgaruccio/code/EEW-Deploy/test.yml:27
Loading collection community.vmware from /Users/michaelgaruccio/.ansible/collections/ansible_collections/community/vmware
Using module file /Users/michaelgaruccio/.local/share/virtualenvs/EEW-Deploy-XQOoyyKX/lib/python3.9/site-packages/ansible_collections/ansible/windows/plugins/modules/win_service.ps1
<EEC-DC01> Attempting python interpreter discovery
[WARNING]: Unhandled error in Python interpreter discovery for host EEC-DC01: unexpected output from Python interpreter discovery
[WARNING]: Platform unknown on host EEC-DC01 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-
core/2.12/reference_appendices/interpreter_discovery.html for more information.
fatal: [EEC-DC01]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "module_stderr": "The system cannot find the path specified.\r\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************************************
EEC-DC01                   : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
localhost                  : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
ansibullbot commented 2 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

mgaruccio commented 2 years ago

!component -ansible-collections/community.aws