1

Since the announcement I'm able to list my Azure infrastructure in the Azure Cloud Shell with ansible.

I want to use it with Windows machines too. I installed the winrm locally as it seems that globally is not supported.

pip install "pywinrm>=0.2.2" --user

With this I understand packages are correctly installed

pywinrm (0.3.0)
requests (2.18.4)
xmltodict (0.11.0)
...

Then I run, with the proper credentials a win ping but ansible complains that the WinRM is not available.

ansible -i workspace/azure_rm.py -m win_ping DC-01

DC-01 | FAILED! => { "msg": "winrm or requests is not installed: No module named xmltodict" }

Is it possible to run ansible in cloud shell with windows hosts?

guillem
  • 2,768
  • 2
  • 30
  • 44

2 Answers2

2

Make sure your windows hosts are setup for WinRM control. That means you should check off a few things are working, you can see what Ansible has to say about it here.

  • Network path is open on TCP port 5985-5986 (try to telnet)
  • Powershell 3.0 or above is installed
  • WinRM remoting has been configured for the remote windows host.
  • Make sure the ansible play is using WinRM port to connect

You can use the excellent PS script ansible provides with a little modification if needed to setup your local certs and configure the box from here.

Tj Kellie
  • 6,336
  • 2
  • 31
  • 40
  • 1
    To me as per the issue message it looks like a missing library issue. I have other windows hosts running with Ansible already (using an ubuntu VM) and had no issue with them. My question was as I have not clear that the Cloud Shell supports WinRM management. – guillem Feb 04 '18 at 16:38
  • does ansible have a service on the windows hosts? What happens when it goes down ? – Rıfat Erdem Sahin Feb 15 '18 at 17:18
  • Ansible does not have a service on the Windows hosts, it operates mainly on WinRM and delivered powershell scripts to run the module commands. – Tj Kellie Feb 16 '18 at 17:08
0

I finally opened a post on MSDN forums and Microsoft identified the missing dependency and added in the Cloud Shell!

enter image description here

Finally it is possible to use Ansible from the Cloud Shell. The only consideration is that the target VM should have internet connectivity on port 5986.

Also there is a sample script to test it.

guillem
  • 2,768
  • 2
  • 30
  • 44