Admin-Ahead Community

Windows => General Windows => Topic started by: arunlalpr on November 15, 2018, 04:21:55 pm

Title: Ansible on Windows
Post by: arunlalpr on November 15, 2018, 04:21:55 pm
Ansible on Windows

We can now manage windows machine using Ansible.

For that, we need to install the following setup in our windows machine.

===========
1. Install Python-winrm to allow Ansible to connect to the Windows machines
2. Upgrade to PowerShell 3.0+ to support Windows modules
3. Enable Windows remoting so that Ansible can connect
============

Windows machines are created the same way as all the other machines that you have
in your inventory.

They are differentiated by the value of the ansible_connection variable.

When ansible_connection is set to winrm , it will try to connect via winrm to Windows PowerShell on the remote machine.

Ansible also uses the ansible_ssh_user , ansible_ssh_pass , and ansible_ssh_port values like it would on your other machine.

However, they use ssh in them, actually try to connect to Windows PowerShell Remoting service by using the
credentials.

 [windows]
test.domain.com
win01.domain.com
win02.domain.com


[windows:vars]
ansible_connection=winrm
ansible_ssh_user=tom
ansible_ssh_pass=s3cr3t
ansible_ssh_port=5757


You can check the connection by using


ansible win01.domain.com -u tom -m win_ping

If everything works correctly, you should see the following output:

===========

win01.domain.com | success >> {
"changed": false,
"ping": "pong"
}

============

That's it :) Try the same your end and let us know the result