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
    pip install “pywinrm=0.2.2”
    ansible windowsserver -m win_ping

    Ansible inventory file sample:
    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 = “”
    $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.



    Previous articleCreate an empty file – Ansible module file
    Next articleAnsible for the Windows Admin by Jeremy Murrah


    1. when I run win_ping module it give following error
      windows | UNREACHABLE! => {
      "changed": false,
      "msg": "ssl: HTTPSConnectionPool(host='', port=5986): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7fb54f4afe50>, 'Connection to timed out. (connect timeout=30)'))",
      "unreachable": true