Ansible Winrm Setup | PowerShell Winrm Setup | Ansible – Winrm basic authentication setup
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/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1”
$file = “$env:tempConfigureRemotingForAnsible.ps1”
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file
Set-Item -Force WSMan:localhostClientAllowunencrypted $True
Set-Item -Force WSMan:localhostServiceAllowunencrypted $True
Set-Item -Force WSMan:localhostServiceauthBasic $True
Note: Make sure run PowerShell as Administration.
If you facing any issue let me know in comments.
Thanks.
source
Leave us a comment Cancel reply
COMMON QUESTIONS
Categories
- Agile Coach
- ARTIFICIAL INTELLIGENCE
- Block chain
- Business Analyst BA
- DATA science
- Development
- Devops Automation
- Dotnet
- Education
- Free Job training and assistance
- Information
- Infrastructure automation
- Interview questions
- JAVA
- jobs
- Learn
- Machine learning
- Python Automation
- QA Automation
- RPA Automation
- SAP crm
- Scrum master Agile
- Skill
- UI Design
- Uncategorized
5 Comments
Ravi Seethai
May 07, 2022 02:57 amSudo dnf update when I pass this command. Command not found . How can I rectify
Karthik S
May 07, 2022 02:57 amGood and simple. Thanks for commands
gaure gundappa
May 07, 2022 02:57 amya it worked for me for python 2.7 version too
Citric acid
May 07, 2022 02:57 amfinally found it…it works
Harsh Singh
May 07, 2022 02:57 amwhen I run win_ping module it give following error
windows | UNREACHABLE! => {
"changed": false,
"msg": "ssl: HTTPSConnectionPool(host='169.254.46.72', port=5986): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7fb54f4afe50>, 'Connection to 169.254.46.72 timed out. (connect timeout=30)'))",
"unreachable": true
}