SlideShare ist ein Scribd-Unternehmen logo
1 von 97
HANDS ON ANSIBLE
INTORDUCTION
8/31/2018 Prepared By Sumit Kumar Chaurasia 1
Wikipedia
Ansible is software that automates
software provisioning, configuration
management, and application
deployment
8/31/2018 Prepared By Sumit Kumar Chaurasia 2
WHAT IS ANSIBLE
• CHANGE MANAGEMENT
• PROVISIONING
• AUTOMATION
• ORCHESTRATION
8/31/2018 Prepared By Sumit Kumar Chaurasia 3
CHANGE MANAGEMENT
Define a “System State”
Doing any kind of configuration changes or system changes.
It can be vary from doing small stuff like editing ssh config file or a big
task as installing or configuring a web server.
8/31/2018 Prepared By Sumit Kumar Chaurasia 4
PROVISIONING
Prepare a system to make it ready
Building servers in any kind of environment , it can vary from your bare
metal physical box to virtual machines or any kind of cloud environment
on demand in very less time.
Examples
• Make an FTP Server
• Make an Email Server
• Make a DB Server
8/31/2018 Prepared By Sumit Kumar Chaurasia 5
8/31/2018 Prepared By Sumit Kumar Chaurasia 6
AUTOMATION
Define tasks to be executed automatically
A set of ordered task to be executed in orderly fashion which include
making decision and running ad-hoc tasks
8/31/2018 Prepared By Sumit Kumar Chaurasia 7
ORCHESTRATION
Coordinates automation BETWEEN systems
8/31/2018 Prepared By Sumit Kumar Chaurasia 8
Why Ansible?
8/31/2018 Prepared By Sumit Kumar Chaurasia 9
8/31/2018 Prepared By Sumit Kumar Chaurasia 10
8/31/2018 Prepared By Sumit Kumar Chaurasia 11
In market we have many automation tools as mentioned below.
For configuration management (Puppet, Chef, cfengine)
Server deployment (Capistrano, Fabric)
Ad-hoc task execution (Func,plain SSH)
With ANSIBLE you will be getting all the above functionality
What makes it so different?
8/31/2018 Prepared By Sumit Kumar Chaurasia 12
8/31/2018 Prepared By Sumit Kumar Chaurasia 13
•It’s clean!
-> No agents
-> No database
-> No residual software
-> No complex upgrades
YAML
•Ansible Execution
-> No programming required
-> Not a markup language
-> Easy to read and write
-> Human readable automation
8/31/2018 Prepared By Sumit Kumar Chaurasia 14
Built-in security
-> Uses SSH
-> Root / Sudo usage
-> Encrypted vault
8/31/2018 Prepared By Sumit Kumar Chaurasia 15
Easy to extend
-> Shell Commands
-> Scripts
-> Ansible-Galaxy
8/31/2018 Prepared By Sumit Kumar Chaurasia 16
8/31/2018 Prepared By Sumit Kumar Chaurasia 17
Architecture and Process Flow
Ansible Architecture
8/31/2018 Prepared By Sumit Kumar Chaurasia 18
Requirements for Control Node
● Ansible software is installed on the control node.
● A machine acting as a control node must have Python 2.6+.
● Red Hat Enterprise Linux 6 or 7 will run Ansible software.
● Windows is not supported for the control node at this time.
8/31/2018 Prepared By Sumit Kumar Chaurasia 19
Requirements on Managed Node
• SSH must be installed and configured to allow incoming connections.
• Managed hosts must have Python 2.4 or later installed.
• The python-simple json package must also be installed on Red Hat
Enterprise Linux 5 managed hosts. It is not required on Red Hat
Enterprise Linux 6 and 7 managed hosts, since Python 2.5 (and newer
versions) provide its functionality by default.
8/31/2018 Prepared By Sumit Kumar Chaurasia 20
Process Flow
8/31/2018 Prepared By Sumit Kumar Chaurasia 21
1. Inventory
Its the list the of “Managed
Hosts” and their connection
configuration.
8/31/2018 Prepared By Sumit Kumar Chaurasia 22
2. Modules
A programmed unit of work to be done.
Core Modules: There are around 500+ core modules that
comes bundled with Ansible
Custom Modules: Users can extend Ansible's
functionality by writing custom modules, which are written
in Python typically, but can also be written in Ruby, Python,
shell etc.
8/31/2018 Prepared By Sumit Kumar Chaurasia 23
3. Playbooks
Ansible playbooks are files written in YAML syntax
that define the modules, with arguments, to apply
to managed nodes. They declare the tasks that
need to be performed.
8/31/2018 Prepared By Sumit Kumar Chaurasia 24
4. Configuration
Ansible have its own config which
manages the behavior of ansible
Default file: /etc/ansible/ansible.cfg
8/31/2018 Prepared By Sumit Kumar Chaurasia 25
8/31/2018 Prepared By Sumit Kumar Chaurasia 26
Ansible Connection Plugins
• Control Persist: A feature that improves Ansible performance by
eliminating SSH connection overhead, when multiple SSH
commands are executed in succession.
• RHEL7 uses default ssh which have “ControlPersist” feature.
• Paramiko: Is a python implementation of ssh with ControlPersist
feature, can be used on RHEL6.(python-paramiko.noarch)
• Local: This plugin is used to connect and manage “control node”
itself.
• winrm: Connection plugin used for managing windows machines.
• Docker: Ansible 2, we have docker plugin as well, which can connect
from Docker host to containers.
8/31/2018 Prepared By Sumit Kumar Chaurasia 27
Installing Ansible
8/31/2018 Prepared By Sumit Kumar Chaurasia 28
● Ansible is required to be installed only on control node,
unlike Puppet or Chef.
● Python3 is not used by ansible as of now.
● Ansible is not a part of RHEL repo ( as of now ). Try
GitHub or EPEL Repos.
● Officially we can get ansible from www.ansible.com
8/31/2018 Prepared By Sumit Kumar Chaurasia 29
8/31/2018 Prepared By Sumit Kumar Chaurasia 30
Ansible Inventory and Configuration
8/31/2018 Prepared By Sumit Kumar Chaurasia 31
Inventory Features
8/31/2018 Prepared By Sumit Kumar Chaurasia 32
Inventory File
[web]
Node1.example.com ansible_ssh_user=ansible ansible_ssh_pass=233
Node2.exmple.com ansible_python_interpreter=/usr/bin/python
[cluster:children]
web
[cluster:vars]
ansible_ssh_user=ansible
ansible_ssh_pass=#######
ntp-server=26.6.6.5
8/31/2018 Prepared By Sumit Kumar Chaurasia 33
Scaling-out Inventory Files
We can have multiple inventories files in directory
8/31/2018 Prepared By Sumit Kumar Chaurasia 34
Static/Dynamic Inventories
• Static Inventory: defined in an INI-like text file, in which
each section defines one group of hosts (a host group)
• Dynamic Inventory: dynamically generated from various
sources. public/private cloud providers, an LDAP database or
CMDB.
• /etc/ansible/hosts is the default inventory
8/31/2018 Prepared By Sumit Kumar Chaurasia 35
Configuration Settings Order-of-Operations
8/31/2018 Prepared By Sumit Kumar Chaurasia 36
Configuration files are not merged.
First one wins!
Configuration files are not merged
First one wins!
8/31/2018 Prepared By Sumit Kumar Chaurasia 37
Configuration File
/etc/ansible/ansible.cfg consist of several sections
8/31/2018 Prepared By Sumit Kumar Chaurasia 38
Before – Doing Actual Things !!
● Before start doing actual things some setup has to
be prepared.
● Remote User should be planned.
● SSH-Key based authentication ( for password less
auth)
● Either Privileges has to be given to the user or not.
● If yes, privilege escalation will be password less ?
8/31/2018 Prepared By Sumit Kumar Chaurasia 39
Running First Ansible Command
• $ ansible –version
8/31/2018 Prepared By Sumit Kumar Chaurasia 40
Running Ad-hoc Command
8/31/2018 Prepared By Sumit Kumar Chaurasia 41
Intro
• Ansible Ad-Hoc commands enable you to perform tasks on remote
nodes without having to write a playbook. They are very useful when
you simply need to do one or two things quickly and often, to many
remote nodes
EXAMPLES
ansible all -m ping
ansible web -m command -a "uptime“
ansible all -m setup
ansible web -m yum -a "name=httpd state=present" -b
8/31/2018 Prepared By Sumit Kumar Chaurasia 42
Ansible command line options
Setting Command-line option
inventory -i
remote_user -u
become --become –b
become_method --become-method
become_user --become-user
become_ask_pass --ask-become-pass -k
8/31/2018 Prepared By Sumit Kumar Chaurasia 43
Ansible Playbooks
8/31/2018 Prepared By Sumit Kumar Chaurasia 44
PLAY
A order set of task which should be
run against hosts selected from
inventory
8/31/2018 Prepared By Sumit Kumar Chaurasia 45
PLAYBOOK
A playbook is a text file that contains a list one or
more plays to run in order. It is saved with
extension .yml
It primarily uses indentation with space
characters to indicate the structure of its data.
8/31/2018 Prepared By Sumit Kumar Chaurasia 46
Playbooks have three keys
1. name: It is optional but recommended to
document the playbook.
2. hosts: Servers on which tasks are executed
3. tasks: Actual work to perform on managed node
8/31/2018 Prepared By Sumit Kumar Chaurasia 47
Format of Playbook
8/31/2018 Prepared By Sumit Kumar Chaurasia 48
Playbook can have multiple plays
8/31/2018 Prepared By Sumit Kumar Chaurasia 49
The order in which the plays
are and tasks are listed in
playbooks is important
because ansible runs them in
same order.
8/31/2018 Prepared By Sumit Kumar Chaurasia 50
Syntax-check For Playbooks
8/31/2018 Prepared By Sumit Kumar Chaurasia 51
Running Playbooks
8/31/2018 Prepared By Sumit Kumar Chaurasia 52
Modules For Tasks
• To Check for the list of modules
[chausum@xpwinno1vscor ~]$ ansible-doc -l | wc -l
1652
• To find module info
8/31/2018 Prepared By Sumit Kumar Chaurasia 53
Simple Playbook Demo
1. Use yum module to install httpd and firewalld
2. Ensure firewalld service is enabled and started
3. Ensure firewalld is configured to allow http connection
4. Ensure httpd service is started and enabled
5. Ensure managed hosts /var/www/html/index.html file consist of
content “Welcome to Ansible World”
8/31/2018 Prepared By Sumit Kumar Chaurasia 54
MANAGING VARIABLES AND
INCLUSIONS
8/31/2018 Prepared By Sumit Kumar Chaurasia 55
Variables can be used to
store value that can be used
throughout files in entire
ansible project
8/31/2018 Prepared By Sumit Kumar Chaurasia 56
Defining Variables
Variables can be defined in variety of places in ansible configuration.
It can be simplified to three basic scope levels:
8/31/2018 Prepared By Sumit Kumar Chaurasia 57
Global Scope Variable set from command line or in ansible configuration
Play Scope Variable set in the play
Host Scope Variable set on host group or individual hosts
DEMO
8/31/2018 Prepared By Sumit Kumar Chaurasia 58
Managing Facts
Ansible facts are variable that are automatically
discovered by ansible on a managed hosts
Facts are collected by using setup module
8/31/2018 Prepared By Sumit Kumar Chaurasia 59
8/31/2018 Prepared By Sumit Kumar Chaurasia 60
Fact Filters
You can use filter in order to limit
the results when gathering facts
from managed node
8/31/2018 Prepared By Sumit Kumar Chaurasia 61
Custom Facts
You can create custom facts which are stored locally on each
managed node2.
By defaults setup loads custom facts from files and scripts on
managed hosts /etc/ansible/facts.d dir. The name of file
should be end with .fact in order to be used.
Custom facts are stored by setup in ansible_local variable
8/31/2018 Prepared By Sumit Kumar Chaurasia 62
IMPLEMENTING TASK CONTROL
8/31/2018 Prepared By Sumit Kumar Chaurasia 63
SIMPLE LOOPS
•Loops iterates a task over a list of items.
•The with_items key is added to the task and
takes as a value the list of items over which the
task should be iterated.
•The loop variable item holds the current value
being used for this iteration
8/31/2018 Prepared By Sumit Kumar Chaurasia 64
EXAMPLE
Without Loop With Loop
8/31/2018 Prepared By Sumit Kumar Chaurasia 65
With_items can be provided by variable also
8/31/2018 Prepared By Sumit Kumar Chaurasia 66
Running Tasks Conditionally
•Ansible uses conditionals to execute tasks or
play when certain conditions are met .
•Playbook variable ,registered variables and
ansible facts can be tested with conditionals
8/31/2018 Prepared By Sumit Kumar Chaurasia 67
Ansible WHEN Statement
•When statement is used to run task
conditionally.
•It takes as a value the condition to check . If
the condition is met , the tasks run. If the
condition is not met, the task is skipped
8/31/2018 Prepared By Sumit Kumar Chaurasia 68
EXAMPLE
8/31/2018 Prepared By Sumit Kumar Chaurasia 69
EXAMPLE-CONTINUED
8/31/2018 Prepared By Sumit Kumar Chaurasia 70
Ansible Handlers
• Handlers are the tasks that respond to a notification triggered by
other task.
• Each handlers has globally-unique name and is triggered at the end of
block of tasks in playbook
• If one or more tasks notify the handlers , It will run exactly once after
all the other tasks in the play have completed
8/31/2018 Prepared By Sumit Kumar Chaurasia 71
EXAMPLE
8/31/2018 Prepared By Sumit Kumar Chaurasia 72
IMPLEMENTING TAGS
• Sometime it is useful to be able to run a particular tasks in a playbook.
Tags can be applied as a text label in order to allow this.
• Tagging only require that the tags keyword be used
# ansible-playbook main.yml --tags ‘webserver’
#ansible-playbook main.yml –skip-tags ‘webserver’
8/31/2018 Prepared By Sumit Kumar Chaurasia 73
Handling Errors
Normally , when a task fails ansible immediately aborts
the rest of the play on that hosts, skipping all
subsequent tasks.
This behavior can be overridden by ignoring failed
tasks.
To do so, the ignore_errors keyword needs to be used in
a task.
8/31/2018 Prepared By Sumit Kumar Chaurasia 74
Forcing Execution Of Handlers
After Task Failure
Normally if a task fails and the play aborts on
that host, any handler which has been
notified by earlier tasks in play will not run. If
you set the force_handlers: yes directive on
the play , then notified handlers will be called
even if the play aborted because a later task
failed
8/31/2018 Prepared By Sumit Kumar Chaurasia 75
Example
8/31/2018 Prepared By Sumit Kumar Chaurasia 76
JINJA2 TEMPLATES
8/31/2018 Prepared By Sumit Kumar Chaurasia 77
INTRO
Managing configurations of multiple servers and environments
are one of the significant uses of Ansible. But these configuration
files may vary for each remote servers or each cluster. But apart from
some few parameters, all other settings will be same.
Creating static files for each of these configurations is not an
efficient solution. And It will take a lot more time and every time a new
cluster is added you will have to add more files. So if there is an
efficient way to manage these dynamic values it would be beneficial.
This is where Ansible template modules come into play.
8/31/2018 Prepared By Sumit Kumar Chaurasia 78
Cont.
Ansible uses Jinja2 templates which ends with .j2 extension. Based on
variables, these templates fill the blanks and generate configurations.
These configurations are then uploaded to the target server.
Example template:
8/31/2018 Prepared By Sumit Kumar Chaurasia 79
Template module
# Example from Ansible Playbooks
- template:
src: /mytemplates/foo.j2
dest: /etc/file.conf
owner: bin
group: wheel
mode: 0644
8/31/2018 Prepared By Sumit Kumar Chaurasia 80
ANSIBLE-VAULT
8/31/2018 Prepared By Sumit Kumar Chaurasia 81
INTRO
Ansible Vault is a feature that allows users to encrypt
values and data structures within Ansible projects. This
provides the ability to secure any sensitive data that is
necessary to successfully run Ansible plays but should
not be publicly visible, like passwords or private keys.
Ansible automatically decrypts vault-encrypted content
at runtime when the key is provided
8/31/2018 Prepared By Sumit Kumar Chaurasia 82
How To Manage Sensitive Files with ansible-vault
The ansible-vault command is the main
interface for managing encrypted
content within Ansible. This command is used
to initially encrypt files
and is subsequently used to view, edit, or
decrypt the data.
8/31/2018 Prepared By Sumit Kumar Chaurasia 83
VAULT TASKS
Creating New Encrypted Files ansible-vault create foo.yml
Editing Encrypted Files ansible-vault edit foo.yml
Rekeying Encrypted Files ansible-vault rekey foo.yml
Decrypting Encrypted Files ansible-vault decrypt foo.yml
Viewing Encrypted Files ansible-vault view foo.yml
8/31/2018 Prepared By Sumit Kumar Chaurasia 84
VAULT USAGE IN PLAYBOOK
Providing Vault Passwords
To be prompted for a vault password, use the --ask-vault-pass cli
option
ansible-playbook --ask-vault-pass site.yml
To specify a vault password in a text file ‘dev-password’, use the --
vault-password-file option
ansible-playbook --vault-password-file dev-password site.yml
8/31/2018 Prepared By Sumit Kumar Chaurasia 85
ANSIBLE ROLES
8/31/2018 Prepared By Sumit Kumar Chaurasia 86
INTRODUCTION
• Ansible roles allow admins to organize playbooks into
separate, smaller playbooks and files.
• It provide a way to load tasks, handlers and variables
from external files.
• Static files and templates can also be associated and
referenced by a role.
8/31/2018 Prepared By Sumit Kumar Chaurasia 87
ANSIBLE ROLE STRUCTURE
• Ansible roles functionality is defined by it
directory structure
•Top level directory defines name of role itself
•Some of directory contain YAML files, named
main.yml
•The files and templates subdirectory can contain
objects referenced by the YAML file
8/31/2018 Prepared By Sumit Kumar Chaurasia 88
EXAMPLE
8/31/2018 Prepared By Sumit Kumar Chaurasia 89
ROLE SUBDIRECTORIES
SUBDIRECTORY FUNCTION
defaults main.yml in this dir contain the default values of roles variables that can be
overwritten when role is used
files This contain static file that are referenced by roles tasks
handlers main.yml in this dir contain the roles handlers definition
meta main.yml in this dir contain information about roles, include author, license etc
tasks main.yml in this dir contain roles tasks definitions
templates This dir contain jinja2 template that are referenced by roles
tests This dir can contain an inventory and test.yml playbook that can be used to test the
role
vars The main.yml file in this dir defines the roles variable values
8/31/2018 Prepared By Sumit Kumar Chaurasia 90
USING ANSIBLE ROLES IN PLAYBOOK
8/31/2018 Prepared By Sumit Kumar Chaurasia 91
CONTROLLING ORDER OF EXECUTION
•Normally the tasks of roles execute before
the tasks of the playbooks that use them.
•Ansible provides a way of overriding this
default behavior with keywords pre_tasks
and post_tasks
8/31/2018 Prepared By Sumit Kumar Chaurasia 92
8/31/2018 Prepared By Sumit Kumar Chaurasia 93
ANSIBLE GALAXY
•Ansible galaxy
(https://galaxy.ansible.com) is a public
library of ansible roles written by variety
of ansible admins and users.
8/31/2018 Prepared By Sumit Kumar Chaurasia 94
ANSIBLE-GALAXY COMMAND LINE TOOL
Search for ansible role
ansible-galaxy search 'nginx' --platforms el
Get info of the role
ansible-galaxy info maruina.nginx
Install the role
ansible-galaxy install maruina.nginx
Create role in offline mode
Ansible-galaxy init --offline role-name
8/31/2018 Prepared By Sumit Kumar Chaurasia 95
Additional Information
•https://docs.ansible.com/
•https://www.ansible.com/resources/we
binars-training
•https://github.com/ansible/lightbulb
8/31/2018 Prepared By Sumit Kumar Chaurasia 96
THANK YOU
8/31/2018 Prepared By Sumit Kumar Chaurasia 97

Weitere ähnliche Inhalte

Was ist angesagt?

Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleCoreStack
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageejlp12
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationKumar Y
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansibleOmid Vahdaty
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleKnoldus Inc.
 
Kubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewKubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewBob Killen
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansibleGeorge Shuklin
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to KubernetesImesh Gunaratne
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practicesBas Meijer
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To JenkinsKnoldus Inc.
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction Robert Reiz
 

Was ist angesagt? (20)

Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and image
 
Network automation (NetDevOps) with Ansible
Network automation (NetDevOps) with AnsibleNetwork automation (NetDevOps) with Ansible
Network automation (NetDevOps) with Ansible
 
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Ansible Automation - Enterprise Use Cases | Juncheng Anthony LinAnsible Automation - Enterprise Use Cases | Juncheng Anthony Lin
Ansible Automation - Enterprise Use Cases | Juncheng Anthony Lin
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Kubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewKubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive Overview
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To Jenkins
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 

Ähnlich wie Hands on ansible

OSDC 2018 | Highly Available Cloud Foundry on Kubernetes by Cornelius Schumacher
OSDC 2018 | Highly Available Cloud Foundry on Kubernetes by Cornelius SchumacherOSDC 2018 | Highly Available Cloud Foundry on Kubernetes by Cornelius Schumacher
OSDC 2018 | Highly Available Cloud Foundry on Kubernetes by Cornelius SchumacherNETWAYS
 
Amazon EC2 deepdive and a sprinkel of AWS Compute | AWS Floor28
Amazon EC2 deepdive and a sprinkel of AWS Compute | AWS Floor28Amazon EC2 deepdive and a sprinkel of AWS Compute | AWS Floor28
Amazon EC2 deepdive and a sprinkel of AWS Compute | AWS Floor28Amazon Web Services
 
ADRecon BH USA 2018 : Arsenal and DEF CON 26 Demo Labs Presentation
ADRecon BH USA 2018 : Arsenal and DEF CON 26 Demo Labs PresentationADRecon BH USA 2018 : Arsenal and DEF CON 26 Demo Labs Presentation
ADRecon BH USA 2018 : Arsenal and DEF CON 26 Demo Labs Presentationprashant3535
 
Network Config Backups - Netbox, Github, Ansible
Network Config Backups - Netbox, Github, AnsibleNetwork Config Backups - Netbox, Github, Ansible
Network Config Backups - Netbox, Github, AnsibleJeremy Schulman
 
Washington DC MuleSoft Meetup 05-12-22-2.pptx
Washington DC MuleSoft Meetup 05-12-22-2.pptxWashington DC MuleSoft Meetup 05-12-22-2.pptx
Washington DC MuleSoft Meetup 05-12-22-2.pptxivaturia
 
Set Up a Million-Core Cluster to Accelerate HPC Workloads (CMP404) - AWS re:I...
Set Up a Million-Core Cluster to Accelerate HPC Workloads (CMP404) - AWS re:I...Set Up a Million-Core Cluster to Accelerate HPC Workloads (CMP404) - AWS re:I...
Set Up a Million-Core Cluster to Accelerate HPC Workloads (CMP404) - AWS re:I...Amazon Web Services
 
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin TimmermannO365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin TimmermannNCCOMMS
 
MuleSoft Meetup Roma - Processi di Automazione su CloudHub
MuleSoft Meetup Roma - Processi di Automazione su CloudHubMuleSoft Meetup Roma - Processi di Automazione su CloudHub
MuleSoft Meetup Roma - Processi di Automazione su CloudHubAlfonso Martino
 
Crossplane and a story about scaling Kubernetes custom resources.pdf
Crossplane and a story about scaling Kubernetes custom resources.pdfCrossplane and a story about scaling Kubernetes custom resources.pdf
Crossplane and a story about scaling Kubernetes custom resources.pdfRichárd Kovács
 
Trends in Systems and How to Get Efficient Performance
Trends in Systems and How to Get Efficient PerformanceTrends in Systems and How to Get Efficient Performance
Trends in Systems and How to Get Efficient Performanceinside-BigData.com
 
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17Muga Nishizawa
 
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 2
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 2MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 2
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 2Alfonso Martino
 
Heroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success storyHeroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success storyJérémy Wimsingues
 
The Quest for the Perfect API
The Quest for the Perfect APIThe Quest for the Perfect API
The Quest for the Perfect APImicrokerneldude
 
Netflix oss season 2 episode 1 - meetup Lightning talks
Netflix oss   season 2 episode 1 - meetup Lightning talksNetflix oss   season 2 episode 1 - meetup Lightning talks
Netflix oss season 2 episode 1 - meetup Lightning talksRuslan Meshenberg
 
Effective administration of IBM Integration Bus - Sanjay Nagchowdhury
Effective administration of IBM Integration Bus - Sanjay NagchowdhuryEffective administration of IBM Integration Bus - Sanjay Nagchowdhury
Effective administration of IBM Integration Bus - Sanjay NagchowdhuryKaren Broughton-Mabbitt
 

Ähnlich wie Hands on ansible (20)

OSDC 2018 | Highly Available Cloud Foundry on Kubernetes by Cornelius Schumacher
OSDC 2018 | Highly Available Cloud Foundry on Kubernetes by Cornelius SchumacherOSDC 2018 | Highly Available Cloud Foundry on Kubernetes by Cornelius Schumacher
OSDC 2018 | Highly Available Cloud Foundry on Kubernetes by Cornelius Schumacher
 
Amazon EC2 deepdive and a sprinkel of AWS Compute | AWS Floor28
Amazon EC2 deepdive and a sprinkel of AWS Compute | AWS Floor28Amazon EC2 deepdive and a sprinkel of AWS Compute | AWS Floor28
Amazon EC2 deepdive and a sprinkel of AWS Compute | AWS Floor28
 
ADRecon BH USA 2018 : Arsenal and DEF CON 26 Demo Labs Presentation
ADRecon BH USA 2018 : Arsenal and DEF CON 26 Demo Labs PresentationADRecon BH USA 2018 : Arsenal and DEF CON 26 Demo Labs Presentation
ADRecon BH USA 2018 : Arsenal and DEF CON 26 Demo Labs Presentation
 
Automation tools: making things go... (March 2019)
Automation tools: making things go... (March 2019)Automation tools: making things go... (March 2019)
Automation tools: making things go... (March 2019)
 
Network Config Backups - Netbox, Github, Ansible
Network Config Backups - Netbox, Github, AnsibleNetwork Config Backups - Netbox, Github, Ansible
Network Config Backups - Netbox, Github, Ansible
 
Washington DC MuleSoft Meetup 05-12-22-2.pptx
Washington DC MuleSoft Meetup 05-12-22-2.pptxWashington DC MuleSoft Meetup 05-12-22-2.pptx
Washington DC MuleSoft Meetup 05-12-22-2.pptx
 
Ci for android OS
Ci for android OSCi for android OS
Ci for android OS
 
Set Up a Million-Core Cluster to Accelerate HPC Workloads (CMP404) - AWS re:I...
Set Up a Million-Core Cluster to Accelerate HPC Workloads (CMP404) - AWS re:I...Set Up a Million-Core Cluster to Accelerate HPC Workloads (CMP404) - AWS re:I...
Set Up a Million-Core Cluster to Accelerate HPC Workloads (CMP404) - AWS re:I...
 
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin TimmermannO365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
O365Con18 - Using ARM Templates to Deploy Solutions on Azure - Kevin Timmermann
 
MuleSoft Meetup Roma - Processi di Automazione su CloudHub
MuleSoft Meetup Roma - Processi di Automazione su CloudHubMuleSoft Meetup Roma - Processi di Automazione su CloudHub
MuleSoft Meetup Roma - Processi di Automazione su CloudHub
 
Crossplane and a story about scaling Kubernetes custom resources.pdf
Crossplane and a story about scaling Kubernetes custom resources.pdfCrossplane and a story about scaling Kubernetes custom resources.pdf
Crossplane and a story about scaling Kubernetes custom resources.pdf
 
Trends in Systems and How to Get Efficient Performance
Trends in Systems and How to Get Efficient PerformanceTrends in Systems and How to Get Efficient Performance
Trends in Systems and How to Get Efficient Performance
 
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
 
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 2
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 2MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 2
MuleSoft Meetup Roma - Runtime Fabric Series (From Zero to Hero) - Sessione 2
 
Heroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success storyHeroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success story
 
Google File System
Google File SystemGoogle File System
Google File System
 
The Quest for the Perfect API
The Quest for the Perfect APIThe Quest for the Perfect API
The Quest for the Perfect API
 
Sprint 68
Sprint 68Sprint 68
Sprint 68
 
Netflix oss season 2 episode 1 - meetup Lightning talks
Netflix oss   season 2 episode 1 - meetup Lightning talksNetflix oss   season 2 episode 1 - meetup Lightning talks
Netflix oss season 2 episode 1 - meetup Lightning talks
 
Effective administration of IBM Integration Bus - Sanjay Nagchowdhury
Effective administration of IBM Integration Bus - Sanjay NagchowdhuryEffective administration of IBM Integration Bus - Sanjay Nagchowdhury
Effective administration of IBM Integration Bus - Sanjay Nagchowdhury
 

Kürzlich hochgeladen

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Hands on ansible

  • 1. HANDS ON ANSIBLE INTORDUCTION 8/31/2018 Prepared By Sumit Kumar Chaurasia 1
  • 2. Wikipedia Ansible is software that automates software provisioning, configuration management, and application deployment 8/31/2018 Prepared By Sumit Kumar Chaurasia 2
  • 3. WHAT IS ANSIBLE • CHANGE MANAGEMENT • PROVISIONING • AUTOMATION • ORCHESTRATION 8/31/2018 Prepared By Sumit Kumar Chaurasia 3
  • 4. CHANGE MANAGEMENT Define a “System State” Doing any kind of configuration changes or system changes. It can be vary from doing small stuff like editing ssh config file or a big task as installing or configuring a web server. 8/31/2018 Prepared By Sumit Kumar Chaurasia 4
  • 5. PROVISIONING Prepare a system to make it ready Building servers in any kind of environment , it can vary from your bare metal physical box to virtual machines or any kind of cloud environment on demand in very less time. Examples • Make an FTP Server • Make an Email Server • Make a DB Server 8/31/2018 Prepared By Sumit Kumar Chaurasia 5
  • 6. 8/31/2018 Prepared By Sumit Kumar Chaurasia 6
  • 7. AUTOMATION Define tasks to be executed automatically A set of ordered task to be executed in orderly fashion which include making decision and running ad-hoc tasks 8/31/2018 Prepared By Sumit Kumar Chaurasia 7
  • 8. ORCHESTRATION Coordinates automation BETWEEN systems 8/31/2018 Prepared By Sumit Kumar Chaurasia 8
  • 9. Why Ansible? 8/31/2018 Prepared By Sumit Kumar Chaurasia 9
  • 10. 8/31/2018 Prepared By Sumit Kumar Chaurasia 10
  • 11. 8/31/2018 Prepared By Sumit Kumar Chaurasia 11 In market we have many automation tools as mentioned below. For configuration management (Puppet, Chef, cfengine) Server deployment (Capistrano, Fabric) Ad-hoc task execution (Func,plain SSH) With ANSIBLE you will be getting all the above functionality
  • 12. What makes it so different? 8/31/2018 Prepared By Sumit Kumar Chaurasia 12
  • 13. 8/31/2018 Prepared By Sumit Kumar Chaurasia 13 •It’s clean! -> No agents -> No database -> No residual software -> No complex upgrades
  • 14. YAML •Ansible Execution -> No programming required -> Not a markup language -> Easy to read and write -> Human readable automation 8/31/2018 Prepared By Sumit Kumar Chaurasia 14
  • 15. Built-in security -> Uses SSH -> Root / Sudo usage -> Encrypted vault 8/31/2018 Prepared By Sumit Kumar Chaurasia 15
  • 16. Easy to extend -> Shell Commands -> Scripts -> Ansible-Galaxy 8/31/2018 Prepared By Sumit Kumar Chaurasia 16
  • 17. 8/31/2018 Prepared By Sumit Kumar Chaurasia 17 Architecture and Process Flow
  • 18. Ansible Architecture 8/31/2018 Prepared By Sumit Kumar Chaurasia 18
  • 19. Requirements for Control Node ● Ansible software is installed on the control node. ● A machine acting as a control node must have Python 2.6+. ● Red Hat Enterprise Linux 6 or 7 will run Ansible software. ● Windows is not supported for the control node at this time. 8/31/2018 Prepared By Sumit Kumar Chaurasia 19
  • 20. Requirements on Managed Node • SSH must be installed and configured to allow incoming connections. • Managed hosts must have Python 2.4 or later installed. • The python-simple json package must also be installed on Red Hat Enterprise Linux 5 managed hosts. It is not required on Red Hat Enterprise Linux 6 and 7 managed hosts, since Python 2.5 (and newer versions) provide its functionality by default. 8/31/2018 Prepared By Sumit Kumar Chaurasia 20
  • 21. Process Flow 8/31/2018 Prepared By Sumit Kumar Chaurasia 21
  • 22. 1. Inventory Its the list the of “Managed Hosts” and their connection configuration. 8/31/2018 Prepared By Sumit Kumar Chaurasia 22
  • 23. 2. Modules A programmed unit of work to be done. Core Modules: There are around 500+ core modules that comes bundled with Ansible Custom Modules: Users can extend Ansible's functionality by writing custom modules, which are written in Python typically, but can also be written in Ruby, Python, shell etc. 8/31/2018 Prepared By Sumit Kumar Chaurasia 23
  • 24. 3. Playbooks Ansible playbooks are files written in YAML syntax that define the modules, with arguments, to apply to managed nodes. They declare the tasks that need to be performed. 8/31/2018 Prepared By Sumit Kumar Chaurasia 24
  • 25. 4. Configuration Ansible have its own config which manages the behavior of ansible Default file: /etc/ansible/ansible.cfg 8/31/2018 Prepared By Sumit Kumar Chaurasia 25
  • 26. 8/31/2018 Prepared By Sumit Kumar Chaurasia 26
  • 27. Ansible Connection Plugins • Control Persist: A feature that improves Ansible performance by eliminating SSH connection overhead, when multiple SSH commands are executed in succession. • RHEL7 uses default ssh which have “ControlPersist” feature. • Paramiko: Is a python implementation of ssh with ControlPersist feature, can be used on RHEL6.(python-paramiko.noarch) • Local: This plugin is used to connect and manage “control node” itself. • winrm: Connection plugin used for managing windows machines. • Docker: Ansible 2, we have docker plugin as well, which can connect from Docker host to containers. 8/31/2018 Prepared By Sumit Kumar Chaurasia 27
  • 28. Installing Ansible 8/31/2018 Prepared By Sumit Kumar Chaurasia 28
  • 29. ● Ansible is required to be installed only on control node, unlike Puppet or Chef. ● Python3 is not used by ansible as of now. ● Ansible is not a part of RHEL repo ( as of now ). Try GitHub or EPEL Repos. ● Officially we can get ansible from www.ansible.com 8/31/2018 Prepared By Sumit Kumar Chaurasia 29
  • 30. 8/31/2018 Prepared By Sumit Kumar Chaurasia 30
  • 31. Ansible Inventory and Configuration 8/31/2018 Prepared By Sumit Kumar Chaurasia 31
  • 32. Inventory Features 8/31/2018 Prepared By Sumit Kumar Chaurasia 32
  • 33. Inventory File [web] Node1.example.com ansible_ssh_user=ansible ansible_ssh_pass=233 Node2.exmple.com ansible_python_interpreter=/usr/bin/python [cluster:children] web [cluster:vars] ansible_ssh_user=ansible ansible_ssh_pass=####### ntp-server=26.6.6.5 8/31/2018 Prepared By Sumit Kumar Chaurasia 33
  • 34. Scaling-out Inventory Files We can have multiple inventories files in directory 8/31/2018 Prepared By Sumit Kumar Chaurasia 34
  • 35. Static/Dynamic Inventories • Static Inventory: defined in an INI-like text file, in which each section defines one group of hosts (a host group) • Dynamic Inventory: dynamically generated from various sources. public/private cloud providers, an LDAP database or CMDB. • /etc/ansible/hosts is the default inventory 8/31/2018 Prepared By Sumit Kumar Chaurasia 35
  • 36. Configuration Settings Order-of-Operations 8/31/2018 Prepared By Sumit Kumar Chaurasia 36
  • 37. Configuration files are not merged. First one wins! Configuration files are not merged First one wins! 8/31/2018 Prepared By Sumit Kumar Chaurasia 37
  • 38. Configuration File /etc/ansible/ansible.cfg consist of several sections 8/31/2018 Prepared By Sumit Kumar Chaurasia 38
  • 39. Before – Doing Actual Things !! ● Before start doing actual things some setup has to be prepared. ● Remote User should be planned. ● SSH-Key based authentication ( for password less auth) ● Either Privileges has to be given to the user or not. ● If yes, privilege escalation will be password less ? 8/31/2018 Prepared By Sumit Kumar Chaurasia 39
  • 40. Running First Ansible Command • $ ansible –version 8/31/2018 Prepared By Sumit Kumar Chaurasia 40
  • 41. Running Ad-hoc Command 8/31/2018 Prepared By Sumit Kumar Chaurasia 41
  • 42. Intro • Ansible Ad-Hoc commands enable you to perform tasks on remote nodes without having to write a playbook. They are very useful when you simply need to do one or two things quickly and often, to many remote nodes EXAMPLES ansible all -m ping ansible web -m command -a "uptime“ ansible all -m setup ansible web -m yum -a "name=httpd state=present" -b 8/31/2018 Prepared By Sumit Kumar Chaurasia 42
  • 43. Ansible command line options Setting Command-line option inventory -i remote_user -u become --become –b become_method --become-method become_user --become-user become_ask_pass --ask-become-pass -k 8/31/2018 Prepared By Sumit Kumar Chaurasia 43
  • 44. Ansible Playbooks 8/31/2018 Prepared By Sumit Kumar Chaurasia 44
  • 45. PLAY A order set of task which should be run against hosts selected from inventory 8/31/2018 Prepared By Sumit Kumar Chaurasia 45
  • 46. PLAYBOOK A playbook is a text file that contains a list one or more plays to run in order. It is saved with extension .yml It primarily uses indentation with space characters to indicate the structure of its data. 8/31/2018 Prepared By Sumit Kumar Chaurasia 46
  • 47. Playbooks have three keys 1. name: It is optional but recommended to document the playbook. 2. hosts: Servers on which tasks are executed 3. tasks: Actual work to perform on managed node 8/31/2018 Prepared By Sumit Kumar Chaurasia 47
  • 48. Format of Playbook 8/31/2018 Prepared By Sumit Kumar Chaurasia 48
  • 49. Playbook can have multiple plays 8/31/2018 Prepared By Sumit Kumar Chaurasia 49
  • 50. The order in which the plays are and tasks are listed in playbooks is important because ansible runs them in same order. 8/31/2018 Prepared By Sumit Kumar Chaurasia 50
  • 51. Syntax-check For Playbooks 8/31/2018 Prepared By Sumit Kumar Chaurasia 51
  • 52. Running Playbooks 8/31/2018 Prepared By Sumit Kumar Chaurasia 52
  • 53. Modules For Tasks • To Check for the list of modules [chausum@xpwinno1vscor ~]$ ansible-doc -l | wc -l 1652 • To find module info 8/31/2018 Prepared By Sumit Kumar Chaurasia 53
  • 54. Simple Playbook Demo 1. Use yum module to install httpd and firewalld 2. Ensure firewalld service is enabled and started 3. Ensure firewalld is configured to allow http connection 4. Ensure httpd service is started and enabled 5. Ensure managed hosts /var/www/html/index.html file consist of content “Welcome to Ansible World” 8/31/2018 Prepared By Sumit Kumar Chaurasia 54
  • 55. MANAGING VARIABLES AND INCLUSIONS 8/31/2018 Prepared By Sumit Kumar Chaurasia 55
  • 56. Variables can be used to store value that can be used throughout files in entire ansible project 8/31/2018 Prepared By Sumit Kumar Chaurasia 56
  • 57. Defining Variables Variables can be defined in variety of places in ansible configuration. It can be simplified to three basic scope levels: 8/31/2018 Prepared By Sumit Kumar Chaurasia 57 Global Scope Variable set from command line or in ansible configuration Play Scope Variable set in the play Host Scope Variable set on host group or individual hosts
  • 58. DEMO 8/31/2018 Prepared By Sumit Kumar Chaurasia 58
  • 59. Managing Facts Ansible facts are variable that are automatically discovered by ansible on a managed hosts Facts are collected by using setup module 8/31/2018 Prepared By Sumit Kumar Chaurasia 59
  • 60. 8/31/2018 Prepared By Sumit Kumar Chaurasia 60
  • 61. Fact Filters You can use filter in order to limit the results when gathering facts from managed node 8/31/2018 Prepared By Sumit Kumar Chaurasia 61
  • 62. Custom Facts You can create custom facts which are stored locally on each managed node2. By defaults setup loads custom facts from files and scripts on managed hosts /etc/ansible/facts.d dir. The name of file should be end with .fact in order to be used. Custom facts are stored by setup in ansible_local variable 8/31/2018 Prepared By Sumit Kumar Chaurasia 62
  • 63. IMPLEMENTING TASK CONTROL 8/31/2018 Prepared By Sumit Kumar Chaurasia 63
  • 64. SIMPLE LOOPS •Loops iterates a task over a list of items. •The with_items key is added to the task and takes as a value the list of items over which the task should be iterated. •The loop variable item holds the current value being used for this iteration 8/31/2018 Prepared By Sumit Kumar Chaurasia 64
  • 65. EXAMPLE Without Loop With Loop 8/31/2018 Prepared By Sumit Kumar Chaurasia 65
  • 66. With_items can be provided by variable also 8/31/2018 Prepared By Sumit Kumar Chaurasia 66
  • 67. Running Tasks Conditionally •Ansible uses conditionals to execute tasks or play when certain conditions are met . •Playbook variable ,registered variables and ansible facts can be tested with conditionals 8/31/2018 Prepared By Sumit Kumar Chaurasia 67
  • 68. Ansible WHEN Statement •When statement is used to run task conditionally. •It takes as a value the condition to check . If the condition is met , the tasks run. If the condition is not met, the task is skipped 8/31/2018 Prepared By Sumit Kumar Chaurasia 68
  • 69. EXAMPLE 8/31/2018 Prepared By Sumit Kumar Chaurasia 69
  • 70. EXAMPLE-CONTINUED 8/31/2018 Prepared By Sumit Kumar Chaurasia 70
  • 71. Ansible Handlers • Handlers are the tasks that respond to a notification triggered by other task. • Each handlers has globally-unique name and is triggered at the end of block of tasks in playbook • If one or more tasks notify the handlers , It will run exactly once after all the other tasks in the play have completed 8/31/2018 Prepared By Sumit Kumar Chaurasia 71
  • 72. EXAMPLE 8/31/2018 Prepared By Sumit Kumar Chaurasia 72
  • 73. IMPLEMENTING TAGS • Sometime it is useful to be able to run a particular tasks in a playbook. Tags can be applied as a text label in order to allow this. • Tagging only require that the tags keyword be used # ansible-playbook main.yml --tags ‘webserver’ #ansible-playbook main.yml –skip-tags ‘webserver’ 8/31/2018 Prepared By Sumit Kumar Chaurasia 73
  • 74. Handling Errors Normally , when a task fails ansible immediately aborts the rest of the play on that hosts, skipping all subsequent tasks. This behavior can be overridden by ignoring failed tasks. To do so, the ignore_errors keyword needs to be used in a task. 8/31/2018 Prepared By Sumit Kumar Chaurasia 74
  • 75. Forcing Execution Of Handlers After Task Failure Normally if a task fails and the play aborts on that host, any handler which has been notified by earlier tasks in play will not run. If you set the force_handlers: yes directive on the play , then notified handlers will be called even if the play aborted because a later task failed 8/31/2018 Prepared By Sumit Kumar Chaurasia 75
  • 76. Example 8/31/2018 Prepared By Sumit Kumar Chaurasia 76
  • 77. JINJA2 TEMPLATES 8/31/2018 Prepared By Sumit Kumar Chaurasia 77
  • 78. INTRO Managing configurations of multiple servers and environments are one of the significant uses of Ansible. But these configuration files may vary for each remote servers or each cluster. But apart from some few parameters, all other settings will be same. Creating static files for each of these configurations is not an efficient solution. And It will take a lot more time and every time a new cluster is added you will have to add more files. So if there is an efficient way to manage these dynamic values it would be beneficial. This is where Ansible template modules come into play. 8/31/2018 Prepared By Sumit Kumar Chaurasia 78
  • 79. Cont. Ansible uses Jinja2 templates which ends with .j2 extension. Based on variables, these templates fill the blanks and generate configurations. These configurations are then uploaded to the target server. Example template: 8/31/2018 Prepared By Sumit Kumar Chaurasia 79
  • 80. Template module # Example from Ansible Playbooks - template: src: /mytemplates/foo.j2 dest: /etc/file.conf owner: bin group: wheel mode: 0644 8/31/2018 Prepared By Sumit Kumar Chaurasia 80
  • 81. ANSIBLE-VAULT 8/31/2018 Prepared By Sumit Kumar Chaurasia 81
  • 82. INTRO Ansible Vault is a feature that allows users to encrypt values and data structures within Ansible projects. This provides the ability to secure any sensitive data that is necessary to successfully run Ansible plays but should not be publicly visible, like passwords or private keys. Ansible automatically decrypts vault-encrypted content at runtime when the key is provided 8/31/2018 Prepared By Sumit Kumar Chaurasia 82
  • 83. How To Manage Sensitive Files with ansible-vault The ansible-vault command is the main interface for managing encrypted content within Ansible. This command is used to initially encrypt files and is subsequently used to view, edit, or decrypt the data. 8/31/2018 Prepared By Sumit Kumar Chaurasia 83
  • 84. VAULT TASKS Creating New Encrypted Files ansible-vault create foo.yml Editing Encrypted Files ansible-vault edit foo.yml Rekeying Encrypted Files ansible-vault rekey foo.yml Decrypting Encrypted Files ansible-vault decrypt foo.yml Viewing Encrypted Files ansible-vault view foo.yml 8/31/2018 Prepared By Sumit Kumar Chaurasia 84
  • 85. VAULT USAGE IN PLAYBOOK Providing Vault Passwords To be prompted for a vault password, use the --ask-vault-pass cli option ansible-playbook --ask-vault-pass site.yml To specify a vault password in a text file ‘dev-password’, use the -- vault-password-file option ansible-playbook --vault-password-file dev-password site.yml 8/31/2018 Prepared By Sumit Kumar Chaurasia 85
  • 86. ANSIBLE ROLES 8/31/2018 Prepared By Sumit Kumar Chaurasia 86
  • 87. INTRODUCTION • Ansible roles allow admins to organize playbooks into separate, smaller playbooks and files. • It provide a way to load tasks, handlers and variables from external files. • Static files and templates can also be associated and referenced by a role. 8/31/2018 Prepared By Sumit Kumar Chaurasia 87
  • 88. ANSIBLE ROLE STRUCTURE • Ansible roles functionality is defined by it directory structure •Top level directory defines name of role itself •Some of directory contain YAML files, named main.yml •The files and templates subdirectory can contain objects referenced by the YAML file 8/31/2018 Prepared By Sumit Kumar Chaurasia 88
  • 89. EXAMPLE 8/31/2018 Prepared By Sumit Kumar Chaurasia 89
  • 90. ROLE SUBDIRECTORIES SUBDIRECTORY FUNCTION defaults main.yml in this dir contain the default values of roles variables that can be overwritten when role is used files This contain static file that are referenced by roles tasks handlers main.yml in this dir contain the roles handlers definition meta main.yml in this dir contain information about roles, include author, license etc tasks main.yml in this dir contain roles tasks definitions templates This dir contain jinja2 template that are referenced by roles tests This dir can contain an inventory and test.yml playbook that can be used to test the role vars The main.yml file in this dir defines the roles variable values 8/31/2018 Prepared By Sumit Kumar Chaurasia 90
  • 91. USING ANSIBLE ROLES IN PLAYBOOK 8/31/2018 Prepared By Sumit Kumar Chaurasia 91
  • 92. CONTROLLING ORDER OF EXECUTION •Normally the tasks of roles execute before the tasks of the playbooks that use them. •Ansible provides a way of overriding this default behavior with keywords pre_tasks and post_tasks 8/31/2018 Prepared By Sumit Kumar Chaurasia 92
  • 93. 8/31/2018 Prepared By Sumit Kumar Chaurasia 93
  • 94. ANSIBLE GALAXY •Ansible galaxy (https://galaxy.ansible.com) is a public library of ansible roles written by variety of ansible admins and users. 8/31/2018 Prepared By Sumit Kumar Chaurasia 94
  • 95. ANSIBLE-GALAXY COMMAND LINE TOOL Search for ansible role ansible-galaxy search 'nginx' --platforms el Get info of the role ansible-galaxy info maruina.nginx Install the role ansible-galaxy install maruina.nginx Create role in offline mode Ansible-galaxy init --offline role-name 8/31/2018 Prepared By Sumit Kumar Chaurasia 95
  • 97. THANK YOU 8/31/2018 Prepared By Sumit Kumar Chaurasia 97