Ansible winrm setup script | pip install pywinrm | ansible winrm example | ansible winrm ps1| ansible winrm | Windows and Linux Communication.
how to connect to windows machine from Linux using ansible?
Hello Guy's ,
Hope you are doing well !!
In this video I will show you , How we can connect Windows and Linux machine through Ansible and Winrm. Please watch complete video.
Please find below commands for Linux:
sudo dnf update
sudo dnf install python3
sudo alternatives --set python /usr/bin/python3
python --version
sudo dnf install python3-virtualenv
virtualenv env
source env/bin/activate
pip install ansible
ansible --version
ansible localhost -m ping
sudo su
sudo mkdir /etc/ansible
cd /etc/ansible
sudo touch hosts
sudo vi hosts
exit
pip install "pywinrm=0.2.2"
ansible windowsserver -m win_ping
Ansible inventory file sample:
[windows]
172.31.16.245
[windows:vars]
ansible_connection = winrm
ansible_user = 'your_windows_machine_username'
ansible_password = "your_windows_machine_password"
ansible_winrm_server_cert_validation = ignore
ansible_winrm_transport = basic
ansible_port = 5985
For Https make sure your port will be 5986
Please find below Windows PowerShell Commands:
$url = "https://raw.githubusercontent.com/ans..."
$file = "$env:temp\ConfigureRemotingForAnsible.ps1"
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file
Set-Item -Force WSMan:\localhost\Client\Allowunencrypted $True
Set-Item -Force WSMan:\localhost\Service\Allowunencrypted $True
Set-Item -Force WSMan:\localhost\Service\auth\Basic $True
Note: Make sure run PowerShell as Administration.
If you facing any issue let me know in comments.
Thanks.