SlideShare a Scribd company logo
1 of 1
Download to read offline
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
Install Ansible
To install Ansible in Debian based Linux, you can follow
the following steps:
#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
Control Node and Manage Node Configuration
Manage Node configuration
For 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.
# Download the below power shell script.
ConfigureRemotingForAnsible.ps1
#Run the power shell script
$ ./ConfigureremotingForAnsible.ps1
# Ensure the Power shell remote login is enabled or not
$ Enable-PSRemoting -Force
# Get version
$ ansible --version
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
Ansible Control Node to communicate with Windows nodes must meet the below requirements
Configuration in Hosts file
Inventory Files & Hosts Pattern
The inventory file of Ansible lists all the platforms you want to automate across. Ansible at
a single instance can work on multiple hosts in the infrastructure. It is also possible to have
multiple inventory files at the same time.
•The host inventory 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 a line break
#Set up hosts by editing the hosts' file in the Ansible
directory
$ sudo vim /etc/ansible/hosts
#To check the connection to hosts #Change your
directory to /etc/Ansible
$ cd /etc/ansible
#Ansible’s win_ping module allows you to check
whether Ansible is connecting to hosts
$ ansible –m win_ping <hosts>
#To check on servers individually
$ ansible –m win_ping server name
#To check a particular server group
$ ansible -m win_ping servergroupname
Follow the below steps to set hosts and
then check their connection:
Set & Check win Hosts Connection Inventory Example
Example inventory file, which you can refer to
understand the various parameters.
Ad-hoc Commands
Ad-Hoc commands are quick commands which are used to perform the actions, that won’t be saved for later.
Frequently used 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
ansible_Hostname
# 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”
Service 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“
File commands
# 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"
Updating Windows
# 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*******
Sample play book
---
- 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
- name: DNS updation
win_dns_client:
adapter_names: "*"
ipv4_addresses:
- 192.168.3.16
- 192.168.3.19
log_path: c:dna_log.txt
Writing & Running play book
# 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”
Ansible windows cheat sheet
Anil Kumar .K
Note: please download the ConfigureRemotingforansible.ps1 from https://raw.githubusercontent.com/ANILVM/powershell/master/ConfigureRemotingForAnsible.ps1

More Related Content

What's hot

Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David KarbanAnsible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karbanansiblebrno
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done rightDan Vaida
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Alex S
 
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Keith Resar
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansibleOmid Vahdaty
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible referencelaonap166
 
Using Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud EnvironmentsUsing Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud Environmentsahamilton55
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to AnsibleDan Vaida
 
Ansible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartAnsible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartHenry Stamerjohann
 
Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaTetiana Saputo
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansibleGeorge Shuklin
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of AnsibleDevOps Ltd.
 
Phoenix Servers with Docker and Nginx
Phoenix Servers with Docker and NginxPhoenix Servers with Docker and Nginx
Phoenix Servers with Docker and NginxNils De Moor
 

What's hot (20)

Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David KarbanAnsible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karban
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
Ansible - Crash course
Ansible - Crash courseAnsible - Crash course
Ansible - Crash course
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
 
Using Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud EnvironmentsUsing Ansible for Deploying to Cloud Environments
Using Ansible for Deploying to Cloud Environments
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to Ansible
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
Ansible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / QuickstartAnsible Meetup Hamburg / Quickstart
Ansible Meetup Hamburg / Quickstart
 
Ansible best practices
Ansible best practicesAnsible best practices
Ansible best practices
 
Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy Mykhailiuta
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 
A tour of Ansible
A tour of AnsibleA tour of Ansible
A tour of Ansible
 
Phoenix Servers with Docker and Nginx
Phoenix Servers with Docker and NginxPhoenix Servers with Docker and Nginx
Phoenix Servers with Docker and Nginx
 

Similar to Ansible windows cheat sheet by anil.k

Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdfNigussMehari4
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansibleahamilton55
 
Ansible Network Automation session1
Ansible Network Automation session1Ansible Network Automation session1
Ansible Network Automation session1Dhruv Sharma
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansibleDharmit Shah
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modulesmohamedmoharam
 
Ansible a tool for dev ops
Ansible a tool for dev opsAnsible a tool for dev ops
Ansible a tool for dev opsRené Ribaud
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestrationPaolo Tonin
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practicesBas Meijer
 
ansible : Infrastructure automation,idempotent and more
ansible : Infrastructure automation,idempotent and moreansible : Infrastructure automation,idempotent and more
ansible : Infrastructure automation,idempotent and moreSabarinath Gnanasekar
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Alex S
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonMyNOG
 
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...VEXXHOST Private Cloud
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleBrian Hogan
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!Jeff Geerling
 

Similar to Ansible windows cheat sheet by anil.k (20)

Ansible_Basics_ppt.pdf
Ansible_Basics_ppt.pdfAnsible_Basics_ppt.pdf
Ansible_Basics_ppt.pdf
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
DevOps for database
DevOps for databaseDevOps for database
DevOps for database
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Ansible Network Automation session1
Ansible Network Automation session1Ansible Network Automation session1
Ansible Network Automation session1
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
 
Ansible a tool for dev ops
Ansible a tool for dev opsAnsible a tool for dev ops
Ansible a tool for dev ops
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestration
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Ansible.pptx
Ansible.pptxAnsible.pptx
Ansible.pptx
 
ansible : Infrastructure automation,idempotent and more
ansible : Infrastructure automation,idempotent and moreansible : Infrastructure automation,idempotent and more
ansible : Infrastructure automation,idempotent and more
 
Ansible
AnsibleAnsible
Ansible
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
 
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and Ansible
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
 
Ansible.pdf
Ansible.pdfAnsible.pdf
Ansible.pdf
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 

Recently uploaded (20)

OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 

Ansible windows cheat sheet by anil.k

  • 1. 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 Install Ansible To install Ansible in Debian based Linux, you can follow the following steps: #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 Control Node and Manage Node Configuration Manage Node configuration For 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. # Download the below power shell script. ConfigureRemotingForAnsible.ps1 #Run the power shell script $ ./ConfigureremotingForAnsible.ps1 # Ensure the Power shell remote login is enabled or not $ Enable-PSRemoting -Force # Get version $ ansible --version 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 Ansible Control Node to communicate with Windows nodes must meet the below requirements Configuration in Hosts file Inventory Files & Hosts Pattern The inventory file of Ansible lists all the platforms you want to automate across. Ansible at a single instance can work on multiple hosts in the infrastructure. It is also possible to have multiple inventory files at the same time. •The host inventory 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 a line break #Set up hosts by editing the hosts' file in the Ansible directory $ sudo vim /etc/ansible/hosts #To check the connection to hosts #Change your directory to /etc/Ansible $ cd /etc/ansible #Ansible’s win_ping module allows you to check whether Ansible is connecting to hosts $ ansible –m win_ping <hosts> #To check on servers individually $ ansible –m win_ping server name #To check a particular server group $ ansible -m win_ping servergroupname Follow the below steps to set hosts and then check their connection: Set & Check win Hosts Connection Inventory Example Example inventory file, which you can refer to understand the various parameters. Ad-hoc Commands Ad-Hoc commands are quick commands which are used to perform the actions, that won’t be saved for later. Frequently used 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 ansible_Hostname # 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” Service 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“ File commands # 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" Updating Windows # 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******* Sample play book --- - 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 - name: DNS updation win_dns_client: adapter_names: "*" ipv4_addresses: - 192.168.3.16 - 192.168.3.19 log_path: c:dna_log.txt Writing & Running play book # 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” Ansible windows cheat sheet Anil Kumar .K Note: please download the ConfigureRemotingforansible.ps1 from https://raw.githubusercontent.com/ANILVM/powershell/master/ConfigureRemotingForAnsible.ps1