Skip to content

Ansible fails in windows servers when using vmware_tools connection and a username not logged in before #1607

Open
@casty8

Description

@casty8
SUMMARY

When I try to execute an automation in a VMWare vCenter virtual machine using the vmware_tools connection method and a username from Active Directory with no previous log in, it fails. If I log in manually to the server I can see that the issue is that the user profile of the user is not created (C:\Users\USER).

I have tested the same automation with WinRM connection and it works. If I manually log in to the server I can see the user profile path has been just created.

IMPORTANT: As the automation I'm developing is for configuring WinRM in some virtual machines we have hosted in VMWare vCenter, I'm forced to use other connection methods (like vmware_tools)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_tools

ANSIBLE VERSION
Automation controller 4.2.0 (Ansible automation platform 2.1)
ansible core 2.13.6
COLLECTION VERSION
community.vmware  3.1.0
CONFIGURATION

OS / ENVIRONMENT

Windows Servers 2016 or later hosted in VMWare vCenter.

STEPS TO REPRODUCE
  1. Create a Windows Server virtual machine in VMWare vCenter and join it to an Active Directory domain.
  2. Execute an ansible automation (something as simple as using the win_file module to create a directory inside the server) against this server using the vmware_tools (ansible_connection) connection method and a user (ansible_vmware_tools_user) from Active Directoy that hasn't logged in to the server before, so his windows user profile is not created yet.
- name: "Pre tasks"
  hosts: localhost
  gather_facts: no
  tasks:
    - name: "Adding host to inventory"
      add_host:
        hostname: "{{ windows_host }}"
        ansible_connection: community.vmware.vmware_tools
        ansible_vmware_host: "{{ vcenter_hostname }}"
        ansible_vmware_user: "{{ vcenter_username }}"
        ansible_vmware_password: "{{ vcenter_password }}"
        ansible_vmware_validate_certs: no
        ansible_shell_type: powershell
        ansible_vmware_tools_user: "{{ ad_username }}"
        ansible_vmware_tools_password: "{{ ad_password }}"
        ansible_vmware_guest_path: "{{ windows__host_folder }}"
        groups: windows

- name: "Role execution"
  hosts: windows
  gather_facts: yes
  tasks:
    - name: "Create temporary dir"
      win_file:
        path: C:\tmp_ansible
        state: directory
EXPECTED RESULTS

Create the directory C:\tmp_ansible inside the Windows Server

ACTUAL RESULTS
TASK [Create temporary dir] ***
[WARNING]: Error deleting remote temporary files (rc: 1, stderr: #< CLIXML
<Objs Version="1.1.0.1"
xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress"
RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>Sy
stem.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing
modules for first use.</AV><AI>0</AI><Nil
/><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><S
S="Error">Remove-Item : Cannot find path
'C:\Users\TEMP\AppData\Local\Temp\ansible-
tmp-1674134258.9689112-102-136885899008081' _x000D__x000A_</S><S
S="Error">because it does not exist._x000D__x000A_</S><S S="Error">At line:2
char:1_x000D__x000A_</S><S S="Error">+ Remove-Item
'C:\Users\TEMP\AppData\Local\Temp\ansible-tmp-1674134258.
..._x000D__x000A_</S><S S="Error">+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~…
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: }
fatal: [wsy01iedi.rmasede.grma.net]: 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)traceback

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions