Normally ansible uses SSH to communicate with hosts, however, for windows we need to use WinRM. We will be follwing the steps outlined in Official Windows Setup
Since we are on Windows 10, we can skip the initial steps of upgrading the powershell and .NET Framework versions. If you are on an older version of windows please follow the steps in upgrading-powershell-and-net-framework.
You will need to manually create an ansible
windows user on your system that is part of the Administrators
group.
You can follow the step in this video: Configure a Windows Host for Ansible - ansible winrm
"There are two main components of the WinRM service that governs how Ansible can interface with the Windows host: the listener and the service configuration settings"
The "script ConfigureRemotingForAnsible.ps1
can be used to set up the basics. This script sets up both HTTP and HTTPS listeners with a self-signed certificate and enables the Basic authentication option on the service."
Note: Open a powershell terminal as Administrator
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
$file = "$env:temp\ConfigureRemotingForAnsible.ps1"
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file
Create a new Inventory named windows-local
Create a new Host
using your Window's Host's IP address. You will need to add the basic authentication varibles using your newly created ansible user.
Note: credential for ansible user will be added later on as an object in AWX
ansible_connection: winrm
ansible_winrm_transport: basic
ansible_winrm_server_cert_validation: ignore
Create a new Credential named windows-ansible-user
.
Any Job Template that will run on your Windows local will need to use these credentials
Create a new Project named windows-test
. This project will use this git repository as its source
Create a new Job Template with the following:
- Name is
hello-world-windows
- Inventory is
windows-local
- Project is
windows-test
- Playbook is /ansible/helloworld_win.yml. This playbook:
- Credentials are
windows-ansible-user
Launch the job