Adding Windows Client to Ansible using WinRM¶
Configuring Window System as Ansible Client¶
Important
Requirements for WinRM to be installed on Windows¶
- Windows Version Supported Windows 7,8.1,10,11, Windows Server 2008, 2008 R2, 2012, 2012 R2, 2016, 2019, 2022
- Powershell 3.0 +
- .Net 4.0+
Create Service Account on windows machine¶
Use lsrmgr.msc to create user
OR Run the below commands to create user from CMD
net user ansible_admin Pa$$321 /add
net localgroup "Administrators" ansible_admin /add
wmic UserAccount where Name="ansible_admin" set PasswordExpires=False
Verify dotnet version¶
Verify winrm version¶
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Get-ItemProperty -Name version -EA 0 | Where { $_.PSChildName -Match '^(?!S)\p{L}'} | Select PSChildName, version
Verify WinRM status¶
Setup WinRM using PS1 script¶
$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
Reverify the WinRM listener¶
Configuring Ansible Controller¶
Ansible inventory file
[windows]
server22 ansible_host=192.168.122.11
[window:vars]
ansible_user=ansible_admin
ansible_password=Pa$$321
ansible_port=5986
ansible_connection=winrm
ansible_winrm_transport=basic
ansible_winrm_server_cert_validation=ignore