• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to configure Windows client setup for Ansible

  • 00:44 lsb_release -a
6729

To Configure Windows client setup for Ansible

Introduction:

Ansible is an open-source automation tool used to manage various configuration and application deployment. It can configure both Unix-like systems as well as Windows systems.

Master Server Requirements:

python3-pip

pywinrm (python package)

Windows Requirements:

powershell 3+

Dot net 4 Step 1: Open the “Power Shell ISE” in windows as Administrator and check the version by using following command

PS C:\WINDOWS\system32> $psversiontable

Name                           Value                                                                                                                                     
----                           -----                                                                                                                                     
PSVersion                      5.1.19041.1237                                                                                                                            
PSEdition                      Desktop                                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                   
BuildVersion                   10.0.19041.1237                                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                                           
WSManStackVersion              3.0                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                       
SerializationVersion           1.1.0.1 

Step 2: Search for “setting up windows host ansible” Snap 1

Step 3: Click on WinRM setup under “setting up windows host ansible” Snap 2

Step 4: Click on Configure Remoting for ansible.ps1 Snap 3

Step 5: Copy the 453 lines of code from , https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 , Paste 453 lines code in powershell Snap 4

PS C:\WINDOWS\system32> #Requires -Version 3.0

# Configure a Windows host for remote management with Ansible
# -----------------------------------------------------------
#
# This script checks the current WinRM (PS Remoting) configuration and makes
# Written by Trond Hindenes <trond@hindenes.com>
# Updated by Chris Church <cchurch@ansible.com>
# Updated by Michael Crilly <mike@autologic.cm>
# Updated by Anton Ouzounov <Anton.Ouzounov@careerbuilder.com>
# Updated by Nicolas Simond <contact@nicolas-simond.com>
# Updated by Dag Wieërs <dag@wieers.com>
# Updated by Jordan Borean <jborean93@gmail.com>
# Updated by Erwan Quélin <erwan.quelin@gmail.com>
# Updated by David Norman <david@dkn.email>

     Write-Log "Unable to establish an HTTP or HTTPS remoting session."
    Throw "Unable to establish an HTTP or HTTPS remoting session."
}
Write-VerboseLog "PS Remoting has been successfully configured for Ansible."
Self-signed SSL certificate generated; thumbprint: 6A907B378A75304BC269621019110F9A264462DF


wxf                 : http://schemas.xmlsoap.org/ws/2004/09/transfer
a                   : http://schemas.xmlsoap.org/ws/2004/08/addressing
w                   : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
lang                : en-US
Address             : http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
ReferenceParameters : ReferenceParameters

Ok.

Step 6: Checking the master server OS version

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute

Step 7: Adding the ansible repository to apt

root@linuxhelp:~# apt-add-repository ppa:ansible/ansible
Repository: 'deb http://ppa.launchpad.net/ansible/ansible/ubuntu/ hirsute main'
Description:
Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.

http://ansible.com/
More info: https://launchpad.net/~ansible/+archive/ubuntu/ansible
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Adding deb entry to /etc/apt/sources.list.d/ansible-ubuntu-ansible-hirsute.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/ansible-ubuntu-ansible-hirsute.list
Adding key to /etc/apt/trusted.gpg.d/ansible-ubuntu-ansible.gpg with fingerprint 6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367
Hit:1 http://in.archive.ubuntu.com/ubuntu hirsute InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu hirsute-updates InRelease [115 kB]                          
Get:3 http://in.archive.ubuntu.com/ubuntu hirsute-backports InRelease [101 kB]                         
Get:4 http://ppa.launchpad.net/ansible/ansible/ubuntu hirsute InRelease [18.1 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu hirsute-updates/main i386 Packages [202 kB]      
Hit:6 http://security.ubuntu.com/ubuntu hirsute-security InRelease                       
Get:7 http://in.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 Packages [406 kB]   
Get:8 http://in.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 DEP-11 Metadata 
Get:15 http://in.archive.ubuntu.com/ubuntu hirsute-updates/multiverse amd64 DEP-11 Metadata [944 B]    
Get:16 http://in.archive.ubuntu.com/ubuntu hirsute-backports/universe amd64 DEP-11 Metadata [9,348 B]  
Get:17 http://ppa.launchpad.net/ansible/ansible/ubuntu hirsute/main amd64 Packages [880 B]      
Get:18 http://ppa.launchpad.net/ansible/ansible/ubuntu hirsute/main Translation-en [516 B]
Fetched 1,588 kB in 2s (866 kB/s)                    
Reading package lists... Done

Step 8: Update the apt after adding the ansible repository

root@linuxhelp:~# apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu hirsute InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu hirsute-updates InRelease                                   
Hit:3 http://in.archive.ubuntu.com/ubuntu hirsute-backports InRelease                                  
Hit:4 http://ppa.launchpad.net/ansible/ansible/ubuntu hirsute InRelease                                
Hit:5 http://security.ubuntu.com/ubuntu hirsute-security InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
263 packages can be upgraded. Run 'apt list --upgradable' to see them.

Step 9: Now install Ansible by using following command

root@linuxhelp:~# apt install ansible
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ansible-core python3-jinja2 python3-packaging python3-pyparsing python3-resolvelib sshpass
Suggested packages:
  python-jinja2-doc python-pyparsing-doc
The following NEW packages will be installed:
  ansible ansible-core python3-jinja2 python3-packaging python3-pyparsing python3-resolvelib sshpass
0 upgraded, 7 newly installed, 0 to remove and 263 not upgraded.
Need to get 21.1 MB of archives.
After this operation, 277 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 python3-jinja2 all 2.11.2-1 [99.8 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 python3-pyparsing all 2.4.7-1 [61.4 kB]   
Get:3 http://ppa.launchpad.net/ansible/ansible/ubuntu hirsute/main amd64 ansible-core all 2.11.6-1ppa~hirsute [927 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 python3-packaging all 20.9-2 [29.9 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu hirsute/universe amd64 python3-resolvelib all 0.5.4-1 [21.6 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu hirsute/universe amd64 sshpass amd64 1.09-1 [11.7 kB]

Step 10:Installing the python package manger

root@linuxhelp:~# apt install python3-pip
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential dpkg-dev fakeroot g++ g++-10 gcc
  gcc-10 gcc-11-base javascript-common libalgorithm-diff-perl libalgorithm-diff-xs-perl
  libalgorithm-merge-perl libasan6 libatomic1 libbinutils libc-dev-bin libc-devtools libc6-dev
  libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libexpat1-dev libfakeroot libgcc-10-dev libgcc-s1
  libgomp1 libitm1 libjs-jquery libjs-sphinxdoc libjs-underscore liblsan0 libnsl-dev libpython3-dev
  libpython3.9 libpython3.9-dev libpython3.9-minimal libpython3.9-stdlib libquadmath0 libstdc++-10-dev
  libstdc++6 libtirpc-dev libtsan0 libubsan1 linux-libc-dev lto-disabled-list make manpages-dev
  python-pip-whl python3-dev python3-distutils python3-lib2to3 python3-setuptools python3-wheel
  python3.9 python3.9-dev python3.9-minimal rpcsvc-proto zlib1g-dev
Suggested packages:
  binutils-doc debian-keyring g++-multilib g++-10-multilib gcc-10-doc gcc-multilib autoconf automake
  libtool flex bison gcc-doc gcc-10-multilib gcc-10-locales apache2 | lighttpd | httpd glibc-doc
  libstdc++-10-doc make-doc python-setuptools-doc python3.9-venv python3.9-doc binfmt-support
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential dpkg-dev fakeroot g++ g++-10 gcc
  gcc-10 javascript-common libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libbinutils libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
  libctf-nobfd0 libctf0 libexpat1-dev libfakeroot libgcc-10-dev libitm1 libjs-jquery libjs-sphinxdoc
  libjs-underscore liblsan0 libnsl-dev libpython3-dev libpython3.9-dev libquadmath0 libstdc++-10-dev
  libtirpc-dev libtsan0 libubsan1 linux-libc-dev lto-disabled-list make manpages-dev python-pip-whl
  python3-dev python3-distutils python3-pip python3-setuptools python3-wheel python3.9-dev
  rpcsvc-proto zlib1g-dev
The following packages will be upgraded:
  gcc-11-base libgcc-s1 libgomp1 libpython3.9 libpython3.9-minimal libpython3.9-stdlib libstdc++6
  python3-lib2to3 python3.9 python3.9-minimal
10 upgraded, 53 newly installed, 0 to remove and 253 not upgraded.
Need to get 56.0 MB/63.3 MB of archives.
After this operation, 216 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 binutils-common amd64 2.36.1-6ubuntu1 [217 kB]

Step 11:Installing the python package pywinrm by using following command

root@linuxhelp:~# pip install pywinrm
Collecting pywinrm
  Downloading pywinrm-0.4.2-py2.py3-none-any.whl (44 kB)
Requirement already satisfied: requests>=2.9.1 in /usr/lib/python3/dist-packages (from pywinrm) (2.25.1)
Collecting requests-ntlm>=0.3.0
  Downloading requests_ntlm-1.1.0-py2.py3-none-any.whl (5.7 kB)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from pywinrm) (1.15.0)
Collecting xmltodict
  Downloading xmltodict-0.12.0-py2.py3-none-any.whl (9.2 kB)
Collecting ntlm-auth>=1.0.2
  Downloading ntlm_auth-1.5.0-py2.py3-none-any.whl (29 kB)
Requirement already satisfied: cryptography>=1.3 in /usr/lib/python3/dist-packages (from requests-ntlm>=0.3.0->pywinrm) (3.3.2)
Installing collected packages: ntlm-auth, xmltodict, requests-ntlm, pywinrm
Successfully installed ntlm-auth-1.5.0 pywinrm-0.4.

Step 12:Adding the windows client in ansible inventory

root@linuxhelp:~# vi /etc/ansible/hosts


[windows]
192.168.6.104

[windows:vars]
ansible_user=Admin
ansible_password=Admin@123
ansible_port=5986
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore

Step 13: Checking the connection with the windows client system

root@linuxhelp:~# ansible windows -m win_ping
192.168.6.104 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

Step 14: Creating an ansible playbook for creating a directory

root@linuxhelp:~# vi test.yml 

- hosts: windows
  gather_facts: true
  tasks:
  - name: create directory
    win_file:
             path: c:\Ansible
             state: directory

Step 15: Checking the syntax of the playbook by using following command

root@linuxhelp:~# ansible-playbook test.yml --syntax-check

playbook: test.yml

Step 16: Run the ansible playbook by using following command

root@linuxhelp:~# ansible-playbook test.yml 

PLAY [windows] *****************************************************************************************

TASK [Gathering Facts] *********************************************************************************
ok: [192.168.6.104]

TASK [create directory] ********************************************************************************
changed: [192.168.6.104]

PLAY RECAP *********************************************************************************************
192.168.6.104              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Step 17: Hence a folder named “Ansible” is created in windows client system Snap 5

with this configuration of windows client setup for ansible have been completed.

Tags:
shanemichel
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What is a playbook in Ansible ?

A

Collection of tasks is known as play and Collection of plays is known as Playbook.

Q

What is python3-pip

A

Pip is a package-management system written in Python used to install and manage python packages.

Q

What is WinRM ?

A

WinRM is a service in windows which is used to communicate remotly.

Q

How Ansible connect to windows servers ?

A

Ansible connects to windows servers by use of WinRM..

Q

Which port does winRM uses ?

A

WinRM uses 5986 port in windows.

Related Tutorials in How to configure Windows client setup for Ansible

Related Tutorials in How to configure Windows client setup for Ansible

How to install Meld tool in Ubuntu
How to install Meld tool in Ubuntu
Feb 25, 2017
How to install Dconf-Editor on Ubuntu 18.04
How to install Dconf-Editor on Ubuntu 18.04
Jul 14, 2018
How to install and update OpenSSL on Ubuntu 16.04
How to install and update OpenSSL on Ubuntu 16.04
Mar 9, 2017
How to install GLib 2.0 on Ubuntu 17.04
How to install GLib 2.0 on Ubuntu 17.04
May 22, 2017
How to Install Android Emulator on Ubuntu 20.4.1
How to Install Android Emulator on Ubuntu 20.4.1
Jul 13, 2021
How To Install AnyDesk on Ubuntu 16.04
How To Install AnyDesk on Ubuntu 16.04
Apr 4, 2018
How to install Genymotion 2.12.1 on Ubuntu 18.04
How to install Genymotion 2.12.1 on Ubuntu 18.04
Jul 9, 2018
How to install Windows 10 VM on Proxmox VE
How to install Windows 10 VM on Proxmox VE
Feb 24, 2018

Related Forums in How to configure Windows client setup for Ansible

Related Forums in How to configure Windows client setup for Ansible

Ubuntu
matthew class=
Failed to enable unit: Refusing to operate on linked unit file sshd.service
Apr 15, 2019
Ubuntu
mason class=
Passwd: You may not view or modify password information for root On Ubuntu 19.04
May 27, 2019
Ubuntu
isaac class=
/etc/apt/sources.list Permission denied
May 18, 2017
Ubuntu
yousuf class=
lsb_release command not working : Debian
Jan 18, 2018
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Ubuntu
mason class=
"E: Package 'php-mcrypt' has no installation candidate" error on Ubuntu 20.4.1
Mar 15, 2021
NFS
luke class=
clnt_create: RPC: Program not registered
Apr 25, 2017
Apache
isaac class=
How to disable apache welcome page on Ubuntu
Dec 15, 2018

Related News in How to configure Windows client setup for Ansible

Related News in How to configure Windows client setup for Ansible

How To Install Mixxx on Ubuntu 16.04
How To Install Mixxx on Ubuntu 16.04
Oct 11, 2017
Ubuntu 17.04 released with greater expectations
Ubuntu 17.04 released with greater expectations
Apr 15, 2017
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Mar 1, 2017
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Sep 2, 2017
Ubuntu Unity is no more: One Linux dream has been axed
Ubuntu Unity is no more: One Linux dream has been axed
Apr 7, 2017
Windows 10 lets Linux run inside Windows after Fall Creators Update
Windows 10 lets Linux run inside Windows after Fall Creators Update
Aug 3, 2017
What’s next for Ubuntu Linux Desktop?
What’s next for Ubuntu Linux Desktop?
Apr 11, 2017
Say Hi to Ubuntu's new mascot
Say Hi to Ubuntu's new mascot
Mar 22, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help David Lopez Guillen ?
Ayuda urgente instale SSL para servidor Opensuse y ahora no funciona tengo servicio web

hola segui este tutorial para tener un certificado ssl y ahora no se ve mi app en la red, espero alguien pueda ayudarme, tengo M9oodle en3.5 en un servidor open suse y ahora no funciona por favor ayuda.

https://www.linuxhelp.com/how-to-create-ssl-certificate-in-opensuse

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.