SlideShare a Scribd company logo
Ansible Hands-on Introduction
By: Rahul Bajaj
@rahulrb0509 Associate Software Engineer, Red Hat
What is Ansible?
It's a simple automation language that can perfectly describe
an IT application infrastructurein Ansible Playbooks.
It's an automation engine that runsAnsible Playbooks.
Ansible Tower is an enterprise framework for controlling,
securing and managing yourAnsible automationwith a UI and
RESTful API.
AnsibleIs...
Installing Ansible
# Install withyum (Example RHEL 7)
$ wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
$ yum localinstall epel-release-7-9.noarch.rpm
$ yum --enablerepo=epel install ansible
# Install using pip
$ pip install ansible
HowAnsibleWorks
Modules
Modules are bits of code transferred to the target system and
executedto satisfy the task declaration. Ansible ships with
several hundred today!
apt/yum
copy
file
get_url
git
ping
debug
service
synchronize
template
Modules Documentation
http://docs.ansible.com/
Modules Documentation
# List out all modulesinstalled
$ ansible-doc -l
...
copy
cron
...
# Read documentation for installedmodule
$ ansible-doc copy
> COPY
The [copy] module copies a file on the local box to remote locations. Use the [fetch] module to copy filesfrom
box.If you need variable interpolationin copied files, use the [template] module.
* note: Thismodule has a corresponding action plugin.
Options (= is mandatory):
...
Modules: Run Commands
If Ansible doesn’t have a module that suits yourneeds there are the
command” modules:
command: Takes the command and executes it on the host. The m
secure and predictable.
shell: Executesthrough a shell like /bin/shsoyou can use pipes etc. B
careful.
script: Runs a local script on a remote node after transferring
raw: Executesa command without going through the Ansible modu
subsystem.
NOTE:Unlike standard modules,run commands have no concept of desired
state and should only be used asa last resort.
Inventory
Inventory is a collection of hosts (nodes) with associated dataand groupin
that Ansible can connect and manage.
Hosts (nodes)
Groups
Inventory-specific data(variables)
Static ordynamic sources
StaticInventory Example
10.42.0.2
10.42.0.6
10.42.0.7
10.42.0.8
10.42.0.100
host.example.com
StaticInventory Example
[control]
control ansible_host=10.42.0.2
[web]
node-[1:3] ansible_host=10.42.0.[6:8]
[haproxy]
haproxy ansible_host=10.42.0.100
[all:vars]
ansible_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
Ad-Hoc Commands
An ad-hoccommand is a single Ansible task to perform quickly, but don’
to save for later.
# check all my inventory hosts are ready to be
# managed by Ansible
$ ansible all -m ping
# collect and display the discovered facts
# for the localhost
$ ansible localhost -m setup
# run the uptime command on all hosts in the
# webgroup
$ ansible web-m command -a "uptime"
Sidebar: Discovered Facts
Facts are bits of informationderived from examining a host systems that
stored asvariablesfor lateruse in a play.
$ ansible localhost -m setup
localhost | success >> {
"ansible_facts": {
"ansible_default_ipv4": {
"address": "192.168.1.37",
"alias": "wlan0",
"gateway": "192.168.1.1",
"interface": "wlan0",
"macaddress": "c4:85:08:3b:a9:16",
"mtu": 1500,
"netmask": "255.255.255.0",
"network": "192.168.1.0",
"type": "ether"
},
Lab # 1:
Ad-HocCommands
Variables
Ansible can work with metadata from various sources and manage the
in the form of variables.
Command line parameters
Plays and tasks
Files
Inventory
Discovered facts
Roles
Tasks
Tasks are the application of a module to perform a specific unit of work.
file: A directory should exist
yum: A package should be installed
service: A service should be running
template: Render a configuration file from a template
get_url: Fetch an archive file from a URL
git: Clone a source code repository
Example Tasks in a Play
tasks:
- name: httpd packageis present
yum:
name: httpd
state: latest
- name: latest index.html file is present
copy:
src: files/index.html
dest: /var/www/html/
- name: restart httpd
service:
name: httpd
state: restarted
Plays & Playbooks
Plays are ordered sets of tasks to execute against host selections from
inventory. A playbookis a file containing one ormore plays.
Lab # 2:
A Simple Playbook
DoingMore withPlaybooks
Here are some more essential playbookfeatures that you can apply:
Templates
Loops
Conditionals
Tags
Blocks
Templates
Ansible embeds that can be used to dynamically:
Set and modifyplay variables
Conditionallogic
Generate files such asconfigurations from variables
Jinja2 templating engine
Loops
Loops can do one task on multiple things,such ascreate a lot of users,
lot of packages, orrepeat a pollingstep untila certain result is reached.
Conditionals
Ansible supports the conditional execution of a task based on the run-tim
evaluation of variable, fact,orprevious task result.
Tags
Tagsare useful to be able to run a subset of a playbookon-demand.
Roles
Roles are a packages of closelyrelated Ansible content that can be sh
easily thanplays alone.
Improvesreadability and maintainability of complex plays
Eases sharing, reuse and standardization of automationprocesses
Enables Ansible content to exist independently of playbooks, projects
even organizations
Provides functional conveniencessuch asfile pathresolution and defau
values
Project withEmbeddedRoles Example
site.yml
roles/
common/
files/
templates/
tasks/
handlers/
vars/
defaults/
meta/
apache/
files/
templates/
tasks/
handlers/
vars/
defaults/
meta/
Project withEmbeddedRoles Example
# site.yml
---
- hosts: web
roles:
- common
- apache
AnsibleGalaxy
http://galaxy.ansible.com
Ansible Galaxyis a hub for finding, reusing and sharing Ansible conten
Jump-start yourautomationprojectwith content contributedand reviewedby
the Ansible community.
Lab #3:
A PlaybookUsing Roles
Lab #4:
Using an Ansible Galaxy Role
Next Steps
It's easy to get started
ansible.com/get-started
Join the Ansible community
ansible.com/community
Would you like to learn a lot more?
redhat.com/en/services/training/do407-automation-ansible

More Related Content

What's hot

Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
Stephane Manciot
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
Knoldus Inc.
 
Ansible
AnsibleAnsible
Ansible
Knoldus Inc.
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
Mehmet Ali Aydın
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Simplilearn
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
CoreStack
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
Bangladesh Network Operators Group
 
Ansible intro
Ansible introAnsible intro
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
Rayed Alrashed
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
Bas Meijer
 
Ansible
AnsibleAnsible
Ansible
Kamil Lelonek
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
Yashar Esmaildokht
 
Ansible
AnsibleAnsible
Ansible
Raul Leite
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
Omid Vahdaty
 
DevOps with Ansible
DevOps with AnsibleDevOps with Ansible
DevOps with Ansible
Swapnil Jain
 
Ansible get started
Ansible get startedAnsible get started
Ansible get started
Rafael Cassau
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
Kumar Y
 
Accelerating with Ansible
Accelerating with AnsibleAccelerating with Ansible
Accelerating with Ansible
Global Knowledge Training
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
Gena Mykhailiuta
 
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
SlideTeam
 

What's hot (20)

Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Ansible
AnsibleAnsible
Ansible
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
Ansible Tutorial For Beginners | What Is Ansible And How It Works? | Ansible ...
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Ansible
AnsibleAnsible
Ansible
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Ansible
AnsibleAnsible
Ansible
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
DevOps with Ansible
DevOps with AnsibleDevOps with Ansible
DevOps with Ansible
 
Ansible get started
Ansible get startedAnsible get started
Ansible get started
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Accelerating with Ansible
Accelerating with AnsibleAccelerating with Ansible
Accelerating with Ansible
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
 

Similar to Ansible

Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
NigussMehari4
 
Intro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetupIntro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetup
Ramesh Godishela
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
MyNOG
 
UNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptxUNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptx
Pandiya Rajan
 
ansible_rhel.pdf
ansible_rhel.pdfansible_rhel.pdf
ansible_rhel.pdf
ssuser6d347b
 
Ansible Devops North East - slides
Ansible Devops North East - slides Ansible Devops North East - slides
Ansible Devops North East - slides
InfinityPP
 
Ansible
AnsibleAnsible
Ansible
Afroz Hussain
 
Ansible_Basics_ppt.pdf
Ansible_Basics_ppt.pdfAnsible_Basics_ppt.pdf
Ansible_Basics_ppt.pdf
PrabhjotSingh976002
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil Davawala
Sahil Davawala
 
DevOps for database
DevOps for databaseDevOps for database
DevOps for database
Osama Mustafa
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
CorkOpenTech
 
Top 50 Ansible Interview Questions And Answers in 2023.pdf
Top 50 Ansible Interview Questions And Answers in 2023.pdfTop 50 Ansible Interview Questions And Answers in 2023.pdf
Top 50 Ansible Interview Questions And Answers in 2023.pdf
Datacademy.ai
 
Ansible a tool for dev ops
Ansible a tool for dev opsAnsible a tool for dev ops
Ansible a tool for dev ops
René Ribaud
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
mohamedmoharam
 
Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)
Jude A. Goonawardena
 
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
M Malai
 
Ansible is Our Wishbone
Ansible is Our WishboneAnsible is Our Wishbone
Ansible is Our Wishbone
Mydbops
 
MongoDB Management & Ansible
MongoDB Management & AnsibleMongoDB Management & Ansible
MongoDB Management & Ansible
MongoDB
 
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
Keith Resar
 
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE LabHow to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
FIWARE
 

Similar to Ansible (20)

Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
Intro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetupIntro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetup
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
 
UNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptxUNIT-I Introduction to Ansible.pptx
UNIT-I Introduction to Ansible.pptx
 
ansible_rhel.pdf
ansible_rhel.pdfansible_rhel.pdf
ansible_rhel.pdf
 
Ansible Devops North East - slides
Ansible Devops North East - slides Ansible Devops North East - slides
Ansible Devops North East - slides
 
Ansible
AnsibleAnsible
Ansible
 
Ansible_Basics_ppt.pdf
Ansible_Basics_ppt.pdfAnsible_Basics_ppt.pdf
Ansible_Basics_ppt.pdf
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil Davawala
 
DevOps for database
DevOps for databaseDevOps for database
DevOps for database
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
 
Top 50 Ansible Interview Questions And Answers in 2023.pdf
Top 50 Ansible Interview Questions And Answers in 2023.pdfTop 50 Ansible Interview Questions And Answers in 2023.pdf
Top 50 Ansible Interview Questions And Answers in 2023.pdf
 
Ansible a tool for dev ops
Ansible a tool for dev opsAnsible a tool for dev ops
Ansible a tool for dev ops
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
 
Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)Introduction to Ansible - (dev ops for people who hate devops)
Introduction to Ansible - (dev ops for people who hate devops)
 
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
Ansible is Our Wishbone(Automate DBA Tasks With Ansible)
 
Ansible is Our Wishbone
Ansible is Our WishboneAnsible is Our Wishbone
Ansible is Our Wishbone
 
MongoDB Management & Ansible
MongoDB Management & AnsibleMongoDB Management & Ansible
MongoDB Management & Ansible
 
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
 
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE LabHow to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
 

Recently uploaded

It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
Zilliz
 
What's New in Teams Calling, Meetings, Devices June 2024
What's New in Teams Calling, Meetings, Devices June 2024What's New in Teams Calling, Meetings, Devices June 2024
What's New in Teams Calling, Meetings, Devices June 2024
Stephanie Beckett
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
sunilverma7884
 
Accelerating Migrations = Recommendations
Accelerating Migrations = RecommendationsAccelerating Migrations = Recommendations
Accelerating Migrations = Recommendations
isBullShit
 
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
alexjohnson7307
 
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Nicolás Lopéz
 
Intel Unveils Core Ultra 200V Lunar chip .pdf
Intel Unveils Core Ultra 200V Lunar chip .pdfIntel Unveils Core Ultra 200V Lunar chip .pdf
Intel Unveils Core Ultra 200V Lunar chip .pdf
Tech Guru
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
bellared2
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
Enterprise Knowledge
 
Semantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software DevelopmentSemantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software Development
Baishakhi Ray
 
The History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal EmbeddingsThe History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal Embeddings
Zilliz
 
Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10
ankush9927
 
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptxMAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
janagijoythi
 
Retrieval Augmented Generation Evaluation with Ragas
Retrieval Augmented Generation Evaluation with RagasRetrieval Augmented Generation Evaluation with Ragas
Retrieval Augmented Generation Evaluation with Ragas
Zilliz
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
AmandaCheung15
 
Sonkoloniya documentation - ONEprojukti.pdf
Sonkoloniya documentation - ONEprojukti.pdfSonkoloniya documentation - ONEprojukti.pdf
Sonkoloniya documentation - ONEprojukti.pdf
SubhamMandal40
 
Mastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for SuccessMastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for Success
David Wilson
 
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
OnBoard
 
Keynote : AI & Future Of Offensive Security
Keynote : AI & Future Of Offensive SecurityKeynote : AI & Future Of Offensive Security
Keynote : AI & Future Of Offensive Security
Priyanka Aash
 
Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024
siddu769252
 

Recently uploaded (20)

It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
 
What's New in Teams Calling, Meetings, Devices June 2024
What's New in Teams Calling, Meetings, Devices June 2024What's New in Teams Calling, Meetings, Devices June 2024
What's New in Teams Calling, Meetings, Devices June 2024
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
 
Accelerating Migrations = Recommendations
Accelerating Migrations = RecommendationsAccelerating Migrations = Recommendations
Accelerating Migrations = Recommendations
 
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
leewayhertz.com-Generative AI tech stack Frameworks infrastructure models and...
 
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024
 
Intel Unveils Core Ultra 200V Lunar chip .pdf
Intel Unveils Core Ultra 200V Lunar chip .pdfIntel Unveils Core Ultra 200V Lunar chip .pdf
Intel Unveils Core Ultra 200V Lunar chip .pdf
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
 
Improving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning ContentImproving Learning Content Efficiency with Reusable Learning Content
Improving Learning Content Efficiency with Reusable Learning Content
 
Semantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software DevelopmentSemantic-Aware Code Model: Elevating the Future of Software Development
Semantic-Aware Code Model: Elevating the Future of Software Development
 
The History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal EmbeddingsThe History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal Embeddings
 
Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10
 
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptxMAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
 
Retrieval Augmented Generation Evaluation with Ragas
Retrieval Augmented Generation Evaluation with RagasRetrieval Augmented Generation Evaluation with Ragas
Retrieval Augmented Generation Evaluation with Ragas
 
Zaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdfZaitechno Handheld Raman Spectrometer.pdf
Zaitechno Handheld Raman Spectrometer.pdf
 
Sonkoloniya documentation - ONEprojukti.pdf
Sonkoloniya documentation - ONEprojukti.pdfSonkoloniya documentation - ONEprojukti.pdf
Sonkoloniya documentation - ONEprojukti.pdf
 
Mastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for SuccessMastering OnlyFans Clone App Development: Key Strategies for Success
Mastering OnlyFans Clone App Development: Key Strategies for Success
 
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
 
Keynote : AI & Future Of Offensive Security
Keynote : AI & Future Of Offensive SecurityKeynote : AI & Future Of Offensive Security
Keynote : AI & Future Of Offensive Security
 
Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024
 

Ansible

  • 1. Ansible Hands-on Introduction By: Rahul Bajaj @rahulrb0509 Associate Software Engineer, Red Hat
  • 2. What is Ansible? It's a simple automation language that can perfectly describe an IT application infrastructurein Ansible Playbooks. It's an automation engine that runsAnsible Playbooks. Ansible Tower is an enterprise framework for controlling, securing and managing yourAnsible automationwith a UI and RESTful API.
  • 4. Installing Ansible # Install withyum (Example RHEL 7) $ wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm $ yum localinstall epel-release-7-9.noarch.rpm $ yum --enablerepo=epel install ansible # Install using pip $ pip install ansible
  • 6. Modules Modules are bits of code transferred to the target system and executedto satisfy the task declaration. Ansible ships with several hundred today! apt/yum copy file get_url git ping debug service synchronize template
  • 8. Modules Documentation # List out all modulesinstalled $ ansible-doc -l ... copy cron ... # Read documentation for installedmodule $ ansible-doc copy > COPY The [copy] module copies a file on the local box to remote locations. Use the [fetch] module to copy filesfrom box.If you need variable interpolationin copied files, use the [template] module. * note: Thismodule has a corresponding action plugin. Options (= is mandatory): ...
  • 9. Modules: Run Commands If Ansible doesn’t have a module that suits yourneeds there are the command” modules: command: Takes the command and executes it on the host. The m secure and predictable. shell: Executesthrough a shell like /bin/shsoyou can use pipes etc. B careful. script: Runs a local script on a remote node after transferring raw: Executesa command without going through the Ansible modu subsystem. NOTE:Unlike standard modules,run commands have no concept of desired state and should only be used asa last resort.
  • 10. Inventory Inventory is a collection of hosts (nodes) with associated dataand groupin that Ansible can connect and manage. Hosts (nodes) Groups Inventory-specific data(variables) Static ordynamic sources
  • 12. StaticInventory Example [control] control ansible_host=10.42.0.2 [web] node-[1:3] ansible_host=10.42.0.[6:8] [haproxy] haproxy ansible_host=10.42.0.100 [all:vars] ansible_user=vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
  • 13. Ad-Hoc Commands An ad-hoccommand is a single Ansible task to perform quickly, but don’ to save for later. # check all my inventory hosts are ready to be # managed by Ansible $ ansible all -m ping # collect and display the discovered facts # for the localhost $ ansible localhost -m setup # run the uptime command on all hosts in the # webgroup $ ansible web-m command -a "uptime"
  • 14. Sidebar: Discovered Facts Facts are bits of informationderived from examining a host systems that stored asvariablesfor lateruse in a play. $ ansible localhost -m setup localhost | success >> { "ansible_facts": { "ansible_default_ipv4": { "address": "192.168.1.37", "alias": "wlan0", "gateway": "192.168.1.1", "interface": "wlan0", "macaddress": "c4:85:08:3b:a9:16", "mtu": 1500, "netmask": "255.255.255.0", "network": "192.168.1.0", "type": "ether" },
  • 16. Variables Ansible can work with metadata from various sources and manage the in the form of variables. Command line parameters Plays and tasks Files Inventory Discovered facts Roles
  • 17. Tasks Tasks are the application of a module to perform a specific unit of work. file: A directory should exist yum: A package should be installed service: A service should be running template: Render a configuration file from a template get_url: Fetch an archive file from a URL git: Clone a source code repository
  • 18. Example Tasks in a Play tasks: - name: httpd packageis present yum: name: httpd state: latest - name: latest index.html file is present copy: src: files/index.html dest: /var/www/html/ - name: restart httpd service: name: httpd state: restarted
  • 19. Plays & Playbooks Plays are ordered sets of tasks to execute against host selections from inventory. A playbookis a file containing one ormore plays.
  • 20. Lab # 2: A Simple Playbook
  • 21. DoingMore withPlaybooks Here are some more essential playbookfeatures that you can apply: Templates Loops Conditionals Tags Blocks
  • 22. Templates Ansible embeds that can be used to dynamically: Set and modifyplay variables Conditionallogic Generate files such asconfigurations from variables Jinja2 templating engine
  • 23. Loops Loops can do one task on multiple things,such ascreate a lot of users, lot of packages, orrepeat a pollingstep untila certain result is reached.
  • 24. Conditionals Ansible supports the conditional execution of a task based on the run-tim evaluation of variable, fact,orprevious task result.
  • 25. Tags Tagsare useful to be able to run a subset of a playbookon-demand.
  • 26. Roles Roles are a packages of closelyrelated Ansible content that can be sh easily thanplays alone. Improvesreadability and maintainability of complex plays Eases sharing, reuse and standardization of automationprocesses Enables Ansible content to exist independently of playbooks, projects even organizations Provides functional conveniencessuch asfile pathresolution and defau values
  • 28. Project withEmbeddedRoles Example # site.yml --- - hosts: web roles: - common - apache
  • 29. AnsibleGalaxy http://galaxy.ansible.com Ansible Galaxyis a hub for finding, reusing and sharing Ansible conten Jump-start yourautomationprojectwith content contributedand reviewedby the Ansible community.
  • 30. Lab #3: A PlaybookUsing Roles Lab #4: Using an Ansible Galaxy Role
  • 31. Next Steps It's easy to get started ansible.com/get-started Join the Ansible community ansible.com/community Would you like to learn a lot more? redhat.com/en/services/training/do407-automation-ansible