Thank you in advance to anyone who helps here. So am unable to run playbooks against our windows AWS instances. I was able to perform a win_ping but when I attempt to run this task on the same instances that I am able to ping I get an SSL Cert error. I have displayed all relevant information down below, let me know if any other information is required.
Try running “ConfigureRemotingForAnsible.ps1” on the windows host you are trying to manage with Ansible.
If that doesn’t work try this command on the ansible host
telnet windows-host-name 5985
telnet windows-host-name 5986
If you see “Trying …” but times out, the maybe the network ACL is not opened.
You can also try removing the existing listeners and then run ConfigureRemotingForAnsible.ps1 which will recreate the self-signed ssl certificate using the following commands
I was just cutting my teeth on executing playbooks against Windows. To add to Tony’s piece about the PowerShell script ConfiguringRemotingforAnsible.ps1 which I had to do I also had to pip install the following on the control machine within side my virtualenv:
For some reason the ansible_winrm_server_cert_validation: ignore var is not being set for your Windows host hence the error. Can you test out the following before your win_stat task when running on the Windows host.
@jordan I completely agree. Although I have clearly stated in the group_vars/windwos.yml file to ignore cert validation it does not appear to acknowledge the setting.
With the tasks/main.yml file now looking like this:
I believe I may know what is happening and this was fixed in the latest devel branch so you can try that out if you like. Looks like it is failing to gather facts before it gets to your debug task, can you set gather_facts: no in your playbook as I’m really curious if the cert validation is being set properly.
A few other things that would be helpful to know
Run pip list and post the output
What version of Ansible are you on
What version of Python 2.7 are you on
If you turn on fact gathering, does it would if you explicitly set the ignore var on the stat task like so
Looks like you are using a dynamic inventory for your AWS hosts, instead of having include_vars to point to the Windows vars file I would create a create an actual windows group in that inventory and add those hosts in there. In the end it would would look something similar to this (untested)
inventory/hosts
[tag_OSType_Windows]
keep empty, is populated in the dynamic inventory
[windows:children]
tag_OSType_Windows
inventory/ec2.py
… keep as normal, just to show how to mix/match dynamic and static inventories
The following is necessary for Python 2.7.9+ when using default WinRM self-signed certificates:
ansible_winrm_server_cert_validation: ignore
playbooks/windows.yml
name: run test on Windows host
hosts: ‘{{target}}’
tasks:
win_stat:
path: C:\Users
From there you would add a tag to the newly created instances OSType: Windows so that when Ansible reads it from the inventory it is automatically put in the Windows group. Even though you are running the playbook on the one host it will inherit the group based on that tag which in turn get’s the Windows vars required.
Hi Jordan, Thank you for the suggestion on the inventory management. We can currently target any instance based on their tags. here is the command I am using to issue the playbook.
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
I believe your issue is that ansible_winrm_server_cert_validation is being loaded with your include_vars directive in the playbook and the way connection vars with Ansible before the current devel branch had a few issues. I would recommend you add