1. Go to the below website and clone the script from the git URL or otherwise manually copy and past in to your target windows machine with name extension ConfigureRemotingForAnsible.ps1
https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#winrm-setup https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 $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) 2.Then run the below command in windows powershell $powershell.exe -ExecutionPolicy ByPass -File .\ConfigureRemotingForAnsible.ps1 it complets the WinRm execution in windows then check the connection through the ansible module by allowing the port address in the security group of the windows instance WinRm_HTTPS = 5986 and WinRm_HTTP = 5985 then enter the inventory by the below format windows1 ansible_host=15.206.72.103 ansible_password=!oC(.WN&UDZ?YhY.Pse%CVa39Z?iKKC ansible_connection=winrm ansible_port=5986 ansible_user=Administrator ansible_winrm_server_cert_validation=ignore Then run the ping module command for checking the target windows machine connection by the below command $ansible -i inventory -m win_ping windows1 Install pywinrm in ansible control machiine apt install python-pip pip install pywinrm
No comments:
Post a Comment