I’ve been pointed to this group for solving the problem with running Robot Framework tests in Windows 10 virtual machine (https://github.com/ansible/ansible/issues/64381).
I’ve successfully run my Robot Framework tests task under various GNU/Linux distributions and desktop environments, but Ansible stuck on that particular task under MS Windows 10. I use ansible_winrm_scheme: http
following this issue as I haven’t managed to provision a Windows machine with the default https.
`
ansible 2.9.0
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/home/ipaleka/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /home/ipaleka/.local/lib/python3.7/site-packages/ansible
executable location = /home/ipaleka/.local/bin/ansible
python version = 3.7.5rc1 (default, Oct 8 2019, 16:47:45) [GCC 9.2.1 20191008]
Host: Linux ubuntu 5.3.0-19-generic #20-Ubuntu SMP Fri Oct 18 09:04:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
VirtualBox: 6.0.14_Ubuntu r132055
pywinrm==0.4.1 # and pywinrm==0.4.0
Guest: Windows 10 OS build 18362.418
`
The following is the Vagrantfile I use:
`
Vagrant.configure(2) do |config|
config.vm.define “winvm” do |winvm|
winvm.vm.box = “StefanScherer/windows_10”
winvm.vm.hostname = “winvm”
winvm.vm.provider “virtualbox” do |vb|
vb.name = “winvm”
end
end
config.vm.provider “virtualbox” do |vb|
vb.gui = true
vb.memory = “3072”
vb.cpus = 1
vb.customize [“modifyvm”, :id, “–vram”, “32”]
end
config.vm.provision “ansible” do |ansible|
ansible.verbose = “v”
ansible.compatibility_mode = “2.0”
ansible.playbook = “setup.yml”
end
config.vm.provision “ansible”, run: ‘always’ do |ansible|
ansible.verbose = “v”
ansible.compatibility_mode = “2.0”
ansible.playbook = “tests.yml”
end
end
`
And these are the relevant Ansible parts:
`
-
name: install Python 3 in MS Windows
hosts: winvm
vars:
ansible_winrm_scheme: http
gather_facts: false
tasks: -
name: installing Python
win_chocolatey:
name: python
version: 3.7.5
state: present -
name: setup MS Windows machine
hosts: winvm
vars:
ansible_winrm_scheme: http
remote_user: vagrant
roles: -
role: setup
-
name: run tests in vagrant
hosts: winvm
vars:
ansible_winrm_scheme: http
remote_user: vagrant
roles: -
role: tests_win
`
All the needed installation parts and the following unit tests task passed:
`
- name: running all unit tests
win_command: “C:\dev\venvs\project\Scripts\activate.bat && pytest”
args:
chdir: “C:\dev\project”
tags: tests
`
but it stuck on the following task:
`
- name: running all functional tests
win_command: “C:\dev\project\tests\functional\robotstart.bat test_start.robot”
args:
chdir: “C:\dev\project\tests\functional”
tags: tests
`
I also tried with
`
- name: running all functional tests
win_psexec:
command: C:\dev\arrangeit\tests\functional\robotstart.bat test_start.robot
interactive: yes
system: yes
tags: tests
`
ans with:
`
- name: running all functional tests
raw: C:\dev\arrangeit\tests\functional\robotstart.bat test_start.robot
become_user: System
tags: tests
`
EXPECTED RESULTS
The same robotstart.bat test_start.robot
command run from command prompt works as expected.
Maybe also worth mentioning is that I have to use environment: DISPLAY: ":0"
variable in the GNU/Linux machines for the same task.
ACTUAL RESULTS
The task stuck. I have tried with win_command
, win_shell
, raw
and script
directives without success. Also by changing executable to cmd, cmd.exe, c:\Windows\System32\cmd.exe, etc., by changing all the possible combinations of relative and absolute path, even by trying to use a service directive win_nssm
(following an issue), in other Windows 10 OS builds, etc., all without success.
I run the playbooks through the Vagrant, so the following is the last part of the output of ANSIBLE_DEBUG=1 vagrant up winvm
:
TASK [tests_win : running all functional tests] ******************************** 22028 1572864232.71069: sending task start callback 22028 1572864232.71073: entering _queue_task() for winvm/win_command 22028 1572864232.71266: worker is 1 (out of 1 available) 22028 1572864232.71300: exiting _queue_task() for winvm/win_command 22028 1572864232.71310: done queuing things up, now waiting for results queue to drain 22028 1572864232.71313: waiting for pending results... 22571 1572864232.71796: running TaskExecutor() for winvm/TASK: tests_win : running all functional tests 22571 1572864232.71843: in run() - task 27c04189-bf46-0fb7-c2fe-000000000021 22571 1572864232.71882: calling self._execute() 22571 1572864232.72019: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/plugins/connection 22571 1572864232.72059: Loading Connection 'winrm' from /home/ipaleka/.local/lib/python3.7/site-packages/ansible/plugins/connection/winrm.py (found_in_cache=True, class_only=False) 22571 1572864232.72072: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/plugins/shell 22571 1572864232.72084: Loading ShellModule 'powershell' from /home/ipaleka/.local/lib/python3.7/site-packages/ansible/plugins/shell/powershell.py (found_in_cache=True, class_only=False) 22571 1572864232.72209: Loading ActionModule 'normal' from /home/ipaleka/.local/lib/python3.7/site-packages/ansible/plugins/action/normal.py (searched paths: /home/ipaleka/.local/lib/python3.7/site-packages/ansible/plugins/action/__pycache__:/home/ipaleka/.local/lib/python3.7/site-packages/ansible/plugins/action) 22571 1572864232.72218: starting attempt loop 22571 1572864232.72221: running the handler 22571 1572864232.73457: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils 22571 1572864232.73555: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/facts 22571 1572864232.73574: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/ecs 22571 1572864232.73581: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/docker 22571 1572864232.73588: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/podman 22571 1572864232.73593: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/k8s 22571 1572864232.73600: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/parsing 22571 1572864232.73606: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/storage 22571 1572864232.73611: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/compat 22571 1572864232.73617: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/distro 22571 1572864232.73622: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/oracle 22571 1572864232.73628: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/identity 22571 1572864232.73633: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/common 22571 1572864232.73650: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/network 22571 1572864232.73675: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/six 22571 1572864232.73681: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/aws 22571 1572864232.73698: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/source_control 22571 1572864232.73705: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/powershell 22571 1572864232.73763: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/__pycache__ 22571 1572864232.73816: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/remote_management 22571 1572864232.73825: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/net_tools 22571 1572864232.73830: trying /home/ipaleka/.local/lib/python3.7/site-packages/ansible/module_utils/csharp 22571 1572864232.74263: _low_level_execute_command(): starting 22571 1572864232.74278: _low_level_execute_command(): executing: PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand JgBjAGgAYwBwAC4AYwBvAG0AIAA2ADUAMAAwADEAIAA+ACAAJABuAHUAbABsAAoAJABlAHgAZQBjAF8AdwByAGEAcABwAGUAcgBfAHMAdAByACAAPQAgACQAaQBuAHAAdQB0ACAAfAAgAE8AdQB0AC0AUwB0AHIAaQBuAGcACgAkAHMAcABsAGkAdABfAHAAYQByAHQAcwAgAD0AIAAkAGUAeABlAGMAXwB3AHIAYQBwAHAAZQByAF8AcwB0AHIALgBTAHAAbABpAHQAKABAACgAIgBgADAAYAAwAGAAMABgADAAIgApACwAIAAyACwAIABbAFMAdAByAGkAbgBnAFMAcABsAGkAdABPAHAAdABpAG8AbgBzAF0AOgA6AFIAZQBtAG8AdgBlAEUAbQBwAHQAeQBFAG4AdAByAGkAZQBzACkACgBJAGYAIAAoAC0AbgBvAHQAIAAkAHMAcABsAGkAdABfAHAAYQByAHQAcwAuAEwAZQBuAGcAdABoACAALQBlAHEAIAAyACkAIAB7ACAAdABoAHIAbwB3ACAAIgBpAG4AdgBhAGwAaQBkACAAcABhAHkAbABvAGEAZAAiACAAfQAKAFMAZQB0AC0AVgBhAHIAaQBhAGIAbABlACAALQBOAGEAbQBlACAAagBzAG8AbgBfAHIAYQB3ACAALQBWAGEAbAB1AGUAIAAkAHMAcABsAGkAdABfAHAAYQByAHQAcwBbADEAXQAKACQAZQB4AGUAYwBfAHcAcgBhAHAAcABlAHIAIAA9ACAAWwBTAGMAcgBpAHAAdABCAGwAbwBjAGsAXQA6ADoAQwByAGUAYQB0AGUAKAAkAHMAcABsAGkAdABfAHAAYQByAHQAcwBbADAAXQApAAoAJgAkAGUAeABlAGMAXwB3AHIAYQBwAHAAZQByAA== 22571 1572864232.74343: checking if winrm_host 127.0.0.1 is an IPv6 address
The following is the output of win_whoami
:
`
TASK [tests_win : win_whoami] **************************************************
ok: [winvm] => {
“account”: {
“account_name”: “vagrant”,
“domain_name”: “WINVM”,
“sid”: “S-1-5-21-2452099938-1091992757-2462325043-1000”,
“type”: “User”
},
“authentication_package”: “NTLM”,
“changed”: false,
“dns_domain_name”: “”,
“groups”: [
{
“account_name”: “None”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”
],
“domain_name”: “WINVM”,
“sid”: “S-1-5-21-2452099938-1091992757-2462325043-513”,
“type”: “Group”
},
{
“account_name”: “Everyone”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”
],
“domain_name”: “”,
“sid”: “S-1-1-0”,
“type”: “WellKnownGroup”
},
{
“account_name”: “Local account and member of Administrators group”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”
],
“domain_name”: “NT AUTHORITY”,
“sid”: “S-1-5-114”,
“type”: “WellKnownGroup”
},
{
“account_name”: “Administrators”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”,
“Owner”
],
“domain_name”: “BUILTIN”,
“sid”: “S-1-5-32-544”,
“type”: “Alias”
},
{
“account_name”: “Users”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”
],
“domain_name”: “BUILTIN”,
“sid”: “S-1-5-32-545”,
“type”: “Alias”
},
{
“account_name”: “NETWORK”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”
],
“domain_name”: “NT AUTHORITY”,
“sid”: “S-1-5-2”,
“type”: “WellKnownGroup”
},
{
“account_name”: “Authenticated Users”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”
],
“domain_name”: “NT AUTHORITY”,
“sid”: “S-1-5-11”,
“type”: “WellKnownGroup”
},
{
“account_name”: “This Organization”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”
],
“domain_name”: “NT AUTHORITY”,
“sid”: “S-1-5-15”,
“type”: “WellKnownGroup”
},
{
“account_name”: “Local account”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”
],
“domain_name”: “NT AUTHORITY”,
“sid”: “S-1-5-113”,
“type”: “WellKnownGroup”
},
{
“account_name”: “NTLM Authentication”,
“attributes”: [
“Mandatory”,
“Enabled by default”,
“Enabled”
],
“domain_name”: “NT AUTHORITY”,
“sid”: “S-1-5-64-10”,
“type”: “WellKnownGroup”
},
{
“account_name”: “High Mandatory Level”,
“attributes”: [
“Integrity”,
“Integrity enabled”
],
“domain_name”: “Mandatory Label”,
“sid”: “S-1-16-12288”,
“type”: “Label”
}
],
“impersonation_level”: “SecurityAnonymous”,
“label”: {
“account_name”: “High Mandatory Level”,
“domain_name”: “Mandatory Label”,
“sid”: “S-1-16-12288”,
“type”: “Label”
},
“login_domain”: “WINVM”,
“login_time”: “2019-11-06T02:45:53.0143972-08:00”,
“logon_id”: 764431,
“logon_server”: “WINVM”,
“logon_type”: “Network”,
“privileges”: {
“SeBackupPrivilege”: “enabled-by-default”,
“SeChangeNotifyPrivilege”: “enabled-by-default”,
“SeCreateGlobalPrivilege”: “enabled-by-default”,
“SeCreatePagefilePrivilege”: “enabled-by-default”,
“SeCreateSymbolicLinkPrivilege”: “enabled-by-default”,
“SeDebugPrivilege”: “enabled-by-default”,
“SeDelegateSessionUserImpersonatePrivilege”: “enabled-by-default”,
“SeImpersonatePrivilege”: “enabled-by-default”,
“SeIncreaseBasePriorityPrivilege”: “enabled-by-default”,
“SeIncreaseQuotaPrivilege”: “enabled-by-default”,
“SeIncreaseWorkingSetPrivilege”: “enabled-by-default”,
“SeLoadDriverPrivilege”: “enabled-by-default”,
“SeManageVolumePrivilege”: “enabled-by-default”,
“SeProfileSingleProcessPrivilege”: “enabled-by-default”,
“SeRemoteShutdownPrivilege”: “enabled-by-default”,
“SeRestorePrivilege”: “enabled-by-default”,
“SeSecurityPrivilege”: “enabled-by-default”,
“SeShutdownPrivilege”: “enabled-by-default”,
“SeSystemEnvironmentPrivilege”: “enabled-by-default”,
“SeSystemProfilePrivilege”: “enabled-by-default”,
“SeSystemtimePrivilege”: “enabled-by-default”,
“SeTakeOwnershipPrivilege”: “enabled-by-default”,
“SeTimeZonePrivilege”: “enabled-by-default”,
“SeUndockPrivilege”: “enabled-by-default”
},
“rights”: [
“SeNetworkLogonRight”,
“SeInteractiveLogonRight”,
“SeBatchLogonRight”,
“SeRemoteInteractiveLogonRight”
],
“token_type”: “TokenPrimary”,
“upn”: “”,
“user_flags”:
}
`
As pointed by @jborean93, that’s the problem with that Session 0, but I can’t get it working interactively. Also, this can’t be solved by using older Windows machines because the plan is to create functional tests in real environment.
TL; DR Can’t run Robot tests (the very first keyword Start Process C:\Program\ Files\Inkscape\inkscape.exe .\resources\sample.svg) from Ansible, while they run as expected from command prompt inside virtual machine.