SlideShare a Scribd company logo
Manage Windows like Linux
using Ansible
Road Map
 1.What is Ansible
 2.Ansible Architecture
 3.Installing Ansible
 4.Inventory Files and host pattern
 5.Configuring Control and Manage
node
 6.Adhoc- commands
 7.Writing and Running Play book
 8.Sample Play book
 9.What is Chocolatey
 10.Why Chocolatey
 11.Demo
What is Ansible
Ansible Is An IT Automation Tool. It Can
Configure Systems, Deploy Software, And Orchestrate
More Advanced IT Tasks Such As Continuous
Deployments Or Zero Downtime Rolling Updates
Ansible Architecture & Installation
#Add Ansible repository
$ sudo apt-add-repository
ppa:ansible/ansible
#Run the update command
$ sudo apt-get update
#Install Ansible package
$ sudo apt-get install ansible
How Ansible Works
Inventory and Host Pattern
The inventory file
of ansible lists all
the platforms you
want to automate
across.
Ansible at a
instance can work
on multiple hosts
in the
infrastructure.
The host
file can contain
hostnames either
individually or in
groups.
Host groups can
be created by
giving a group
name within
square brackets.
Group members
can then be listed
under, till there is
line break.
Inventory Example
Configuration of Control Node
and Managed Node
Control Node Configuration
For Ansible to communicate to a Windows host and use Windows modules,
the Control host must meet the following requirements:
• A WinRM must be installed and activated .
• pywinrm with support for basic, certificate, and NTLM auth, simply activated
#To install pywinrm with support for basic,
certificate, and NTLM auth, simply
$ Pip install pywinrm
# for Debian/Ubuntu/etc:
$ sudo apt-get install python-dev libkrb5-dev
$ pip install pywinrm
# for RHEL/CentOS/etc:
$ sudo yum install gcc krb5-devel krb5-workstation
$ pip install pywinrm
Managed Node Configuration
Ansible to communicate to a Windows host and use Windows modules, the Windows host must meet
the following requirements:
• Ansible’s supported Windows versions generally match those under current and extended support
from Microsoft. Supported desktop OSs include Windows 7, 8.1, and 10, and supported server OSs
are Windows Server 2008, 2008 R2, 2012, 2012 R2, 2016, and 2019.
• Ansible requires PowerShell 3.0 or newer and at least .NET 4.0 to be installed on the Windows host.
• A WinRM listener should be created and activated. More details for this can be found below.
# Ensure the Power shell remote login is enabled or
not
$ Enable-PSRemoting -Force
# Get version
$ ansible --version
# Download the below power shell script.
ConfigureRemotingForAnsible.ps1
#Run the power shell script
$ ./ConfigureremotingForAnsible.ps1
WINRM Configuration
Windows Event Log
Verbose
Cert Validity
ForceNewSSLCert
EnableCredSSP
DisableBasicAuth
Skip N/w Profile check
Windows Configuration
Ad-hoc Commands
Frequently used and File Commands
# To check ping status.
$ ansible [host_group_name_in_inventory_file] -i hosts -m
win_ping
# Gathering Hostnames
$ ansible [host_group_name_in_inventory_file] -i hosts -m
setup | grep Host_name
# Start the service
$ ansible [host_group_name_in_inventory_file] -m
win_service –a "name=ser _name“
# check specific file is exist or not
$ ansible [host_group_name] -m win_file –a
“path=c:filename” , “state=touch”
# Create a Directory
$ ansible [host_group] -i hosts -m win_file –a
“path=c:directory name state=directory”
# deleting a directory
$ ansible [host_group] -i hosts -m win_file –a
“path=c:directory name state=absent”
# download a file or image using url
$ ansible [host_group] -m win_get_url -a
"url=https://www.somewebsite.com/ansible.jpg
dest=c:fileansible.jpg"
Service and Update Commands
# Start the service in all the servers
$ ansible [host_group] -m win_service –a "name=ser _name
state=started“
# Retart the service in the servers
$ ansible [host_group] -m win_service –a "name=ser _name
state=restarted“
# Stop the service in servers
$ ansible [host_group] -m win_service –a "name=ser _name
state=stopped“
# Pause the service in servers
$ ansible [host_group] -m win_service –a "name=ser _name
state=pause“
# Install only security updates as a scheduled task for
Server
win_updates:
category_names: SecurityUpdates
use_scheduled_task: yes
# Install only particular updates based on the KB
numbers
win_updates:
category_name: - SecurityUpdates
whitelist:
- KB*******
- KB*******
Writing and Running Playbook
# writing a play book
$ vim play_book name.yaml
(or)
$ vim play_book.yml
# Run a play book
$ ansible-playbook –m Module name –a arguments –i
inventory
# Run a play book interactively
$ ansible –playbook_name –step
# Run a play book at a particular task
$ ansible-playbook playbook-name.yml --start-at-
task=“task_name”
---
- name: Getting started First play book
hosts: win
tasks:
- name: Create directory structure
win_file:
path: C:Tempshellscripts
state: directory
- name: copy a shell script
win_copy:
src: /etc/ansible/localuser.ps1
dest: c:Tempshellscripts
- name: run the powershell script
win_shell: c:Tempshellscriptslocaluser.ps1 >> c:script.txt
- name: create a user using ansible module
win_user:
name: Level3
password: Pass@123
state: present
groups:
- administrators
- users
Managing windows Nodes like Linux Nodes by Ansible
What is Chocolatey ?
Chocolatey is a package
manager for Windows (like apt-get
or yum but for Windows). It was
designed to be
a decentralized framework for quickly
installing applications and tools that
you need.
 Package Manager for Windows
 Behaves much like Yum
 Uses NuGet packaging framework +
PowerShell for automation scripts
 CLI tool - choco.exe
 Allows non-centralized/private
repositories
 Secure
 Flexibility & GUI interface
Chocolatey integrates with your favorite configuration
manager
Managing windows Nodes like Linux Nodes by Ansible
DEMO
Managing windows Nodes like Linux Nodes by Ansible
Managing windows Nodes like Linux Nodes by Ansible

More Related Content

PDF
Ansible windows cheat sheet by anil.k
PPTX
Advance discussion on Ansible - Rahul Inti
PDF
Ansible + WordPress - WordCamp Toronto 2016
PPTX
Basics of Ansible - Sahil Davawala
PPTX
Introduction to Ansible
PPTX
Ansible presentation
PDF
Automation with ansible
PPTX
Ansible for beginners
Ansible windows cheat sheet by anil.k
Advance discussion on Ansible - Rahul Inti
Ansible + WordPress - WordCamp Toronto 2016
Basics of Ansible - Sahil Davawala
Introduction to Ansible
Ansible presentation
Automation with ansible
Ansible for beginners

What's hot (20)

PDF
Ansible Introduction - Ansible Brno #1 - David Karban
PDF
Ansible roles done right
PDF
StackiFest16: Building a Cart
PPTX
Ansible Network Automation session1
PDF
IT Automation with Ansible
PPTX
Ansible - Crash course
PDF
Ansible is the simplest way to automate. MoldCamp, 2015
PDF
Jenkins and ansible reference
PPTX
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
PDF
StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce
PPTX
Introduction to ansible
PDF
Introducing Ansible
PDF
Ansible best practices
PDF
Ansible Meetup Hamburg / Quickstart
PPT
Ansible presentation
PDF
Configuration Management in Ansible
PPTX
Best practices for ansible
PDF
StackiFest 16: Stacki Overview- Anoop Rajendra
PDF
Phoenix Servers with Docker and Nginx
Ansible Introduction - Ansible Brno #1 - David Karban
Ansible roles done right
StackiFest16: Building a Cart
Ansible Network Automation session1
IT Automation with Ansible
Ansible - Crash course
Ansible is the simplest way to automate. MoldCamp, 2015
Jenkins and ansible reference
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
StackiFest16: Stacki 1600+ Server Journey - Dave Peterson, Salesforce
Introduction to ansible
Introducing Ansible
Ansible best practices
Ansible Meetup Hamburg / Quickstart
Ansible presentation
Configuration Management in Ansible
Best practices for ansible
StackiFest 16: Stacki Overview- Anoop Rajendra
Phoenix Servers with Docker and Nginx
Ad

Similar to Managing windows Nodes like Linux Nodes by Ansible (20)

PPTX
SESSION Ansible how to deploy and push resources
PPTX
Mastering_Ansible_PAnsible_Presentation our score increases as you pick a
PPTX
Ansible
PDF
Ansible is the simplest way to automate. SymfonyCafe, 2015
PDF
Ansible Automation to Rule Them All
PDF
ansible_rhel.pdf
PPTX
Ansible as configuration management tool for devops
PDF
Automated Deployment and Configuration Engines. Ansible
PPTX
Intro to-ansible-sep7-meetup
PPTX
Ansible Devops North East - slides
PDF
Ansible_Basics_ppt.pdf
PDF
Ansible Tutorial.pdf
PPTX
Ansible: What, Why & How
PDF
#OktoCampus - Workshop : An introduction to Ansible
PDF
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
PDF
Ansible - Hands on Training
PDF
Ansible at work
PDF
Ansible
ODP
ansible why ?
PDF
Ansible101
SESSION Ansible how to deploy and push resources
Mastering_Ansible_PAnsible_Presentation our score increases as you pick a
Ansible
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible Automation to Rule Them All
ansible_rhel.pdf
Ansible as configuration management tool for devops
Automated Deployment and Configuration Engines. Ansible
Intro to-ansible-sep7-meetup
Ansible Devops North East - slides
Ansible_Basics_ppt.pdf
Ansible Tutorial.pdf
Ansible: What, Why & How
#OktoCampus - Workshop : An introduction to Ansible
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017
Ansible - Hands on Training
Ansible at work
Ansible
ansible why ?
Ansible101
Ad

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Electronic commerce courselecture one. Pdf
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation theory and applications.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Programs and apps: productivity, graphics, security and other tools
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
The Rise and Fall of 3GPP – Time for a Sabbatical?
Spectral efficient network and resource selection model in 5G networks
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
Electronic commerce courselecture one. Pdf
Cloud computing and distributed systems.
Encapsulation theory and applications.pdf
Machine learning based COVID-19 study performance prediction
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Per capita expenditure prediction using model stacking based on satellite ima...

Managing windows Nodes like Linux Nodes by Ansible

  • 1. Manage Windows like Linux using Ansible
  • 2. Road Map  1.What is Ansible  2.Ansible Architecture  3.Installing Ansible  4.Inventory Files and host pattern  5.Configuring Control and Manage node  6.Adhoc- commands  7.Writing and Running Play book  8.Sample Play book  9.What is Chocolatey  10.Why Chocolatey  11.Demo
  • 3. What is Ansible Ansible Is An IT Automation Tool. It Can Configure Systems, Deploy Software, And Orchestrate More Advanced IT Tasks Such As Continuous Deployments Or Zero Downtime Rolling Updates
  • 4. Ansible Architecture & Installation #Add Ansible repository $ sudo apt-add-repository ppa:ansible/ansible #Run the update command $ sudo apt-get update #Install Ansible package $ sudo apt-get install ansible
  • 6. Inventory and Host Pattern The inventory file of ansible lists all the platforms you want to automate across. Ansible at a instance can work on multiple hosts in the infrastructure. The host file can contain hostnames either individually or in groups. Host groups can be created by giving a group name within square brackets. Group members can then be listed under, till there is line break.
  • 8. Configuration of Control Node and Managed Node
  • 9. Control Node Configuration For Ansible to communicate to a Windows host and use Windows modules, the Control host must meet the following requirements: • A WinRM must be installed and activated . • pywinrm with support for basic, certificate, and NTLM auth, simply activated #To install pywinrm with support for basic, certificate, and NTLM auth, simply $ Pip install pywinrm # for Debian/Ubuntu/etc: $ sudo apt-get install python-dev libkrb5-dev $ pip install pywinrm # for RHEL/CentOS/etc: $ sudo yum install gcc krb5-devel krb5-workstation $ pip install pywinrm
  • 10. Managed Node Configuration Ansible to communicate to a Windows host and use Windows modules, the Windows host must meet the following requirements: • Ansible’s supported Windows versions generally match those under current and extended support from Microsoft. Supported desktop OSs include Windows 7, 8.1, and 10, and supported server OSs are Windows Server 2008, 2008 R2, 2012, 2012 R2, 2016, and 2019. • Ansible requires PowerShell 3.0 or newer and at least .NET 4.0 to be installed on the Windows host. • A WinRM listener should be created and activated. More details for this can be found below. # Ensure the Power shell remote login is enabled or not $ Enable-PSRemoting -Force # Get version $ ansible --version # Download the below power shell script. ConfigureRemotingForAnsible.ps1 #Run the power shell script $ ./ConfigureremotingForAnsible.ps1
  • 11. WINRM Configuration Windows Event Log Verbose Cert Validity ForceNewSSLCert EnableCredSSP DisableBasicAuth Skip N/w Profile check Windows Configuration
  • 13. Frequently used and File Commands # To check ping status. $ ansible [host_group_name_in_inventory_file] -i hosts -m win_ping # Gathering Hostnames $ ansible [host_group_name_in_inventory_file] -i hosts -m setup | grep Host_name # Start the service $ ansible [host_group_name_in_inventory_file] -m win_service –a "name=ser _name“ # check specific file is exist or not $ ansible [host_group_name] -m win_file –a “path=c:filename” , “state=touch” # Create a Directory $ ansible [host_group] -i hosts -m win_file –a “path=c:directory name state=directory” # deleting a directory $ ansible [host_group] -i hosts -m win_file –a “path=c:directory name state=absent” # download a file or image using url $ ansible [host_group] -m win_get_url -a "url=https://www.somewebsite.com/ansible.jpg dest=c:fileansible.jpg"
  • 14. Service and Update Commands # Start the service in all the servers $ ansible [host_group] -m win_service –a "name=ser _name state=started“ # Retart the service in the servers $ ansible [host_group] -m win_service –a "name=ser _name state=restarted“ # Stop the service in servers $ ansible [host_group] -m win_service –a "name=ser _name state=stopped“ # Pause the service in servers $ ansible [host_group] -m win_service –a "name=ser _name state=pause“ # Install only security updates as a scheduled task for Server win_updates: category_names: SecurityUpdates use_scheduled_task: yes # Install only particular updates based on the KB numbers win_updates: category_name: - SecurityUpdates whitelist: - KB******* - KB*******
  • 15. Writing and Running Playbook # writing a play book $ vim play_book name.yaml (or) $ vim play_book.yml # Run a play book $ ansible-playbook –m Module name –a arguments –i inventory # Run a play book interactively $ ansible –playbook_name –step # Run a play book at a particular task $ ansible-playbook playbook-name.yml --start-at- task=“task_name” --- - name: Getting started First play book hosts: win tasks: - name: Create directory structure win_file: path: C:Tempshellscripts state: directory - name: copy a shell script win_copy: src: /etc/ansible/localuser.ps1 dest: c:Tempshellscripts - name: run the powershell script win_shell: c:Tempshellscriptslocaluser.ps1 >> c:script.txt - name: create a user using ansible module win_user: name: Level3 password: Pass@123 state: present groups: - administrators - users
  • 17. What is Chocolatey ? Chocolatey is a package manager for Windows (like apt-get or yum but for Windows). It was designed to be a decentralized framework for quickly installing applications and tools that you need.  Package Manager for Windows  Behaves much like Yum  Uses NuGet packaging framework + PowerShell for automation scripts  CLI tool - choco.exe  Allows non-centralized/private repositories  Secure  Flexibility & GUI interface
  • 18. Chocolatey integrates with your favorite configuration manager
  • 20. DEMO

Editor's Notes

  • #5: Let us start with Public/Private Cloud which is the Linux server. It can also act as a repository for all IT installation and configurations. The above architecture has a bunch of host machines to which ansible server connects and pushes the playbooks through SSH. It has ansible automation engine using which users can directly run a playbook which gets deployed on the hosts. There are multiple components in the ansible automation engine. The first is a host inventory. It’s a list of all the IP addresses of all the hosts. Next, there are modules. Ansible comes with hundreds of inbuilt modules and modules are those pieces of code that get executed when you run a playbook. A playbook contains plays, a play contains different tasks, and a task includes modules. When you run a playbook, it’s the modules that get executed on your hosts, and these modules contain action in them. So, when you run a playbook, those action takes place on your host machines. You can make your custom modules also. All you must do is write a few lines of code and make it your module, and you can run it anytime you want. Then the architecture has playbooks. Playbooks here actually define your workflow because whatever tasks that you write in a playbook, it gets executed in the same order that you have written them. For example, if you have written that install a package first and then start, it’ll do the same. Playbooks are very simple to write YAML code. YAML code is a very simple data serialization language; it’s pretty much like English. Next, in the architecture are plugins. Plugins here are special kind of modules. These plugins get executed before a module is getting executed on the nodes. Plugins get executed on the main control machine for logging purposes. You’ve got call-back plugins because this enables you to hook into different ansible events for display and logging purposes. Cache plugins are used to keep a cache of facts to avoid costly fact-gathering operations. Ansible also has action plugins, which are front-end modules, and they can execute tasks on the controller machine before calling the modules themselves. The architecture has connection plugins. It is not always needed to use an SSH for connecting with your host machines; you can also use a connection plug-in. For example, ansible provides you with a docker container connection plugin and using that connection plug-in, you can easily connect to all your Docker containers and start configuring right away.
  • #6: Ansible works by connecting to nodes and pushing out small programs called as ansible modules. Ansible then executes these modules over SSH or WinRM by default and then remove them when finished. Ansible management node is the controlling node, which controls the entire execution of the Playbook. It’s the node from which you are running the installation, and the inventory file provides the list of the host where the modules need to be run. The management node makes ssh connection, and then it executes the modules on the host machines and installs the product. It removes the modules once they are installed. That’s how ansible works.