SlideShare a Scribd company logo
1 of 23
Download to read offline
Automating with
ansible (part B)
Iman darabi
https://www.linkedin.com/in/imandarabi/
Table of contents
( part A - Basics )
1. History
2. Introduction
a. Why ansible
b. Understanding YAML
3. Basics getting started
a. Setting up ansible
b. Managing configuration and Inventory
c. Ad-hoc commands
d. Working with modules
e. Understanding playbooks
f. Variables, includes, imports and facts
g. Understanding Jinja2 templates
4. Working with roles
○ Understanding role structure
○ Creating roles
○ Deploying roles with ansible galaxy
○ Using the ansible galaxy CLI utility
Iman Darabi
https://www.linkedin.com/in/imandarabi/
Table of contents
( part B - DevOps )
1. Implementing DevOps Using Vagrant with Ansible
2. Understanding DevOps
3. Provisioning Vagrant Machines
4. Integrating Vagrant with Ansible
5. Creating a Vagrant Development Environment
6. Completing the Vagrant DevOps Environment
7.
Iman Darabi
https://www.linkedin.com/in/imandarabi/
Understanding DevOps
● DevOps tends to integrate developers and operations departments
● The goal is to build and manage essential components with automated programmatic
procedures
● Infrastructure as Code (IaC) is a key component
●
Infrastructure as a Code
● infrastructure as code replaces manual infrastructure operations
● Manual operations are replaced with code
● As a result it’s easy to consistently deploy and replicate operations throughout an
environment
● Ansible is an IaC solution, which automates server configuration and software installation
● A challenge is how to manage this infrastructure code
●
Managing IaC
● A version control system such as Git should be used to manage different versions of
Ansible code
● Using version control, the different states of infrastructure code can be managed
○ Development
○ Production
● Doing so allows administrators to test code before taking it to production
Vagrant
● It is essential to ensure that code in the test environment is the same as code in a
production environment
● Vagrant can be used to streamline creation and configuration of virtual development
environments
● Using its own language, Vagrant manages virtualization software such as KVM,
VirtualBox, and VMware through providers
● Vagrant can also interact with Ansible, Puppet, Salt, and Chef
● Vagrant automate VM creation, including hardware settings, software installation and
system configuration
● Vagrant can be used to create the basic Ansible managed environment
Vagrant Components
● Vagrant consist of two major components: Vagrant and Box
● Vagrant is what automates the build and configuration of virtual machines
● It’s available as a separate download at vagrantup.com
● A box is a tar file that contains a VM image
○ The image should contain just a base OS install
○ The base image can be used as a starting point for creating different VMs
● Public preconfigured Box images are available at vagrantcloud.com
● The Vagrantfile is a plain text file containing the instructions for creating the Vagrant
environment
●
Creating Vagrantfile
● A Vagrantfile always contains the following minimal contents
○ The Box image file to use
○ The URL where the Box image file is found
○ The target hostname
● Vagrant file example:
○ Vagrant.configure(2) do |config| config.vm.box = “rhel7.1”
○ Config.vm.box_url =
○ “http://vagrant.example.com/ansible2.0/x86_64/dvd/vagrant/rhel-server-libvirt-7.1x86_64.box”
○ Config.vm.hostname = “vagrant1.example.com”
○ end
Managing Vagrant Machines
● vagrant up : from the root of the project directory to bring up the target VM
● vagrant ssh: connects as the vagrant user on the target machine
● vagrant halt: stop VM
● Vagrant destroy: stop and cleanup a VM
Vagrant Synced folders
● A synced folder copies the contents of the project directory to a directory ~/sync/ on the
Vagrant machine
● Make sure that rsync is installed for this to work
Vagrant provisioning
● Vagrant provisioning uses the base
Box image and applies software
installation and configuration
updates as an overlay to that
● Provisioners are called from
Vagrantfile, using
“configvm.provision”
● Different types of provisioners are
available, the shell provisioner is the
most basic one
Vagrant.configure(2) do |config|
… Configuration omitted …
Config.vm.provision “shell”, inline: <<- SHELL
Sudo cp
/home/vagrant/sync/etc/yum.repos.d/*
/etc/yum.repos.d
SHELL
… Configuration omitted …
Setting up Vagrant with libvirt
● Download vagrant file:
https://releases.hashicorp.com/vagrant/2.2.15/vagrant_2.2.15_linux_amd64.zip
● # apt install qemu libvirt-daemon-system libvirt-clients libxslt1-dev libxml2-dev
libvirt-dev zlib1g-dev ruby-dev ruby-libvirt ebtables dnsmasq-base libguestfs-tools gcc
rsync libarchive-tools virt-manager
● # vagrant plugin install vagrant-libvirt
● # vagrant plugin install vagrant-disksize
● # vagrant box add generic/ubuntu2004 --provider libvirt
Example
● Create a project directory:
○ # mkdir -p ~/vagrant/test1
● In this directory, create a Vagrantfile with the following contents
○ Vagrant.configure(“2”) do |config|
○ config.vm.box = “ubuntu/2004”
○ End
● Start VM: # vagrant up [--provider=libvirt]
● Ssh to VM: # vagrant ssh <image>
● Stop VM: # vagrant destroy
Integrating Vagrant with
Ansible
Understanding Provisioner Types
● The bash provisioner can be used to run shell code
● The ansible provisioner runs Ansible on the Vagrant host
○ Ansible works as control node
○ Vagrant machines work as managed hosts
● The ansible_local provisioner runs Ansible on the Vgrant machines
●
Configuring Vagrant for Ansible Provisioning
● The example below shows how the ansible provisioner is used to run the playbook.yml file
after deploying the base OS
● Make sure that the playbook.yml is available in the current directory
○ Vagrant.configure (2) do |config|
○ …
○ config.vm.provision “ansible” do | ansible”
○ ansible.playbook = ‘playbook.yml’
○ end
○ …
○ End
● If you want to run playbooks again without rebuilding VM run:
○ # vagrant provision
Creating a Vagrant
Development Environment
Understanding Further Integration
● In a development environment, you need code versions to be managed on the Vagrant
machine
● Ansible has different source control modules that work with version control software like
Git and Subversion
● You can use it, for instance, to populate a web application Document root using the git
module in Ansible
Ansible Git Example
● …
○ - name: get code
○ git:
○ repo: ssh://user@server1/home/user/git/webapp.git
○ dest: /var/www/html
○ accept_hostkey: yes
● ...
Using Forwarded Ports
● To make a deployed application accessible, Vagrant can use forwarded ports
● Forwarded ports map network ports on the host system to ports on the Vagrant machine
and thus make it accessible
● Vagrant.configure(2) do |config|
● …
● config.vm.network: forwarded_port, guest: 80, host: 8080
● end
Version Control and IaC
● Place Vagrant + Ansible in a version control system to manage it in an easy way
● Just put the Vagrant project directory in Git to make it happen
● New administrators then just have to use git clone to make the software locally available,
followed by vagrant up to recreate the Vagrant development environment
● Just make sure the Git repository has the most recent version of the code
● This solution allows for a clean separation of tasks, where developers take care of code,
and operations takes care of new software versions
Lab: combining Vagrant and Ansible
● Create a Vagrantfile to install the latest version of ubuntu as a machine with the name
lab.example.com
● From the Vagrantfile, call an Ansible playbook that installs the Apache webserver and
opens the firewall to allow access to the webserver
● Configure Vagrant port forwarding such that port 8000 on the Vagrant host forwards
traffic to the Apache process on the Vagrant installed machine

More Related Content

What's hot

Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done rightDan Vaida
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestrationbcoca
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102APNIC
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible referencelaonap166
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Alex S
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them AllTim Fairweather
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganCorkOpenTech
 
Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaTetiana Saputo
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Idan Tohami
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupGreg DeKoenigsberg
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationKumar Y
 
Development of Ansible modules
Development of Ansible modulesDevelopment of Ansible modules
Development of Ansible modulesjtyr
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricksbcoca
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleCoreStack
 
Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David KarbanAnsible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karbanansiblebrno
 

What's hot (20)

Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
 
Ansible 202 - sysarmy
Ansible 202 - sysarmyAnsible 202 - sysarmy
Ansible 202 - sysarmy
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
 
Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy Mykhailiuta
 
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetup
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Development of Ansible modules
Development of Ansible modulesDevelopment of Ansible modules
Development of Ansible modules
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Ansible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David KarbanAnsible Introduction - Ansible Brno #1 - David Karban
Ansible Introduction - Ansible Brno #1 - David Karban
 

Similar to Automating with ansible (Part B)

Take Home Your Very Own Free Vagrant CFML Dev Environment
Take Home Your Very Own Free Vagrant CFML Dev Environment Take Home Your Very Own Free Vagrant CFML Dev Environment
Take Home Your Very Own Free Vagrant CFML Dev Environment ColdFusionConference
 
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....Gavin Pickin
 
Vagrant 101 Workshop
Vagrant 101 WorkshopVagrant 101 Workshop
Vagrant 101 WorkshopLiora Milbaum
 
Magento Docker Setup.pdf
Magento Docker Setup.pdfMagento Docker Setup.pdf
Magento Docker Setup.pdfAbid Malik
 
Vagrant are you still develop in a non-virtual environment-
Vagrant  are you still develop in a non-virtual environment-Vagrant  are you still develop in a non-virtual environment-
Vagrant are you still develop in a non-virtual environment-Anatoly Bubenkov
 
Varying WordPress Development Environment WordCamp Columbus 2016
Varying WordPress Development Environment WordCamp Columbus 2016Varying WordPress Development Environment WordCamp Columbus 2016
Varying WordPress Development Environment WordCamp Columbus 2016David Brattoli
 
Node.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ BenetechNode.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ BenetechChristopher Bumgardner
 
Varying wordpressdevelopmentenvironment wp-campus2016
Varying wordpressdevelopmentenvironment wp-campus2016Varying wordpressdevelopmentenvironment wp-campus2016
Varying wordpressdevelopmentenvironment wp-campus2016David Brattoli
 
Development with Vagrant
Development with VagrantDevelopment with Vagrant
Development with VagrantJohn Coggeshall
 
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 -  Working with Wercker WorksheetsOracle Developers APAC Meetup #1 -  Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 - Working with Wercker WorksheetsDarrel Chia
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for DevelopersJohn Coggeshall
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Hendrik Ebbers
 
ITB2019 Scaling with CommandBox in Production! - Brad Wood
ITB2019 Scaling with CommandBox in Production! - Brad WoodITB2019 Scaling with CommandBox in Production! - Brad Wood
ITB2019 Scaling with CommandBox in Production! - Brad WoodOrtus Solutions, Corp
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized DevelopmentAdam Culp
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for DevelopersJohn Coggeshall
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for DevelopersJohn Coggeshall
 
Varying WordPress Development Environment WordCamp Cincinnati 2016
Varying WordPress Development Environment WordCamp Cincinnati 2016Varying WordPress Development Environment WordCamp Cincinnati 2016
Varying WordPress Development Environment WordCamp Cincinnati 2016David Brattoli
 
Vagrant workshop 2015
Vagrant workshop 2015Vagrant workshop 2015
Vagrant workshop 2015Haifa Ftirich
 

Similar to Automating with ansible (Part B) (20)

Take Home Your Very Own Free Vagrant CFML Dev Environment
Take Home Your Very Own Free Vagrant CFML Dev Environment Take Home Your Very Own Free Vagrant CFML Dev Environment
Take Home Your Very Own Free Vagrant CFML Dev Environment
 
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
Take home your very own free Vagrant CFML Dev Environment - Presented at dev....
 
Vagrant 101 Workshop
Vagrant 101 WorkshopVagrant 101 Workshop
Vagrant 101 Workshop
 
Magento Docker Setup.pdf
Magento Docker Setup.pdfMagento Docker Setup.pdf
Magento Docker Setup.pdf
 
Vagrant are you still develop in a non-virtual environment-
Vagrant  are you still develop in a non-virtual environment-Vagrant  are you still develop in a non-virtual environment-
Vagrant are you still develop in a non-virtual environment-
 
Varying WordPress Development Environment WordCamp Columbus 2016
Varying WordPress Development Environment WordCamp Columbus 2016Varying WordPress Development Environment WordCamp Columbus 2016
Varying WordPress Development Environment WordCamp Columbus 2016
 
Node.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ BenetechNode.js, Vagrant, Chef, and Mathoid @ Benetech
Node.js, Vagrant, Chef, and Mathoid @ Benetech
 
Varying wordpressdevelopmentenvironment wp-campus2016
Varying wordpressdevelopmentenvironment wp-campus2016Varying wordpressdevelopmentenvironment wp-campus2016
Varying wordpressdevelopmentenvironment wp-campus2016
 
Development with Vagrant
Development with VagrantDevelopment with Vagrant
Development with Vagrant
 
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 -  Working with Wercker WorksheetsOracle Developers APAC Meetup #1 -  Working with Wercker Worksheets
Oracle Developers APAC Meetup #1 - Working with Wercker Worksheets
 
Vagrantfordevops
VagrantfordevopsVagrantfordevops
Vagrantfordevops
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013
 
ITB2019 Scaling with CommandBox in Production! - Brad Wood
ITB2019 Scaling with CommandBox in Production! - Brad WoodITB2019 Scaling with CommandBox in Production! - Brad Wood
ITB2019 Scaling with CommandBox in Production! - Brad Wood
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized Development
 
Ansible & Vagrant
Ansible & VagrantAnsible & Vagrant
Ansible & Vagrant
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Varying WordPress Development Environment WordCamp Cincinnati 2016
Varying WordPress Development Environment WordCamp Cincinnati 2016Varying WordPress Development Environment WordCamp Cincinnati 2016
Varying WordPress Development Environment WordCamp Cincinnati 2016
 
Vagrant workshop 2015
Vagrant workshop 2015Vagrant workshop 2015
Vagrant workshop 2015
 

Recently uploaded

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 

Recently uploaded (20)

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 

Automating with ansible (Part B)

  • 1. Automating with ansible (part B) Iman darabi https://www.linkedin.com/in/imandarabi/
  • 2. Table of contents ( part A - Basics ) 1. History 2. Introduction a. Why ansible b. Understanding YAML 3. Basics getting started a. Setting up ansible b. Managing configuration and Inventory c. Ad-hoc commands d. Working with modules e. Understanding playbooks f. Variables, includes, imports and facts g. Understanding Jinja2 templates 4. Working with roles ○ Understanding role structure ○ Creating roles ○ Deploying roles with ansible galaxy ○ Using the ansible galaxy CLI utility Iman Darabi https://www.linkedin.com/in/imandarabi/
  • 3. Table of contents ( part B - DevOps ) 1. Implementing DevOps Using Vagrant with Ansible 2. Understanding DevOps 3. Provisioning Vagrant Machines 4. Integrating Vagrant with Ansible 5. Creating a Vagrant Development Environment 6. Completing the Vagrant DevOps Environment 7. Iman Darabi https://www.linkedin.com/in/imandarabi/
  • 4. Understanding DevOps ● DevOps tends to integrate developers and operations departments ● The goal is to build and manage essential components with automated programmatic procedures ● Infrastructure as Code (IaC) is a key component ●
  • 5. Infrastructure as a Code ● infrastructure as code replaces manual infrastructure operations ● Manual operations are replaced with code ● As a result it’s easy to consistently deploy and replicate operations throughout an environment ● Ansible is an IaC solution, which automates server configuration and software installation ● A challenge is how to manage this infrastructure code ●
  • 6. Managing IaC ● A version control system such as Git should be used to manage different versions of Ansible code ● Using version control, the different states of infrastructure code can be managed ○ Development ○ Production ● Doing so allows administrators to test code before taking it to production
  • 7. Vagrant ● It is essential to ensure that code in the test environment is the same as code in a production environment ● Vagrant can be used to streamline creation and configuration of virtual development environments ● Using its own language, Vagrant manages virtualization software such as KVM, VirtualBox, and VMware through providers ● Vagrant can also interact with Ansible, Puppet, Salt, and Chef ● Vagrant automate VM creation, including hardware settings, software installation and system configuration ● Vagrant can be used to create the basic Ansible managed environment
  • 8. Vagrant Components ● Vagrant consist of two major components: Vagrant and Box ● Vagrant is what automates the build and configuration of virtual machines ● It’s available as a separate download at vagrantup.com ● A box is a tar file that contains a VM image ○ The image should contain just a base OS install ○ The base image can be used as a starting point for creating different VMs ● Public preconfigured Box images are available at vagrantcloud.com ● The Vagrantfile is a plain text file containing the instructions for creating the Vagrant environment ●
  • 9. Creating Vagrantfile ● A Vagrantfile always contains the following minimal contents ○ The Box image file to use ○ The URL where the Box image file is found ○ The target hostname ● Vagrant file example: ○ Vagrant.configure(2) do |config| config.vm.box = “rhel7.1” ○ Config.vm.box_url = ○ “http://vagrant.example.com/ansible2.0/x86_64/dvd/vagrant/rhel-server-libvirt-7.1x86_64.box” ○ Config.vm.hostname = “vagrant1.example.com” ○ end
  • 10. Managing Vagrant Machines ● vagrant up : from the root of the project directory to bring up the target VM ● vagrant ssh: connects as the vagrant user on the target machine ● vagrant halt: stop VM ● Vagrant destroy: stop and cleanup a VM
  • 11. Vagrant Synced folders ● A synced folder copies the contents of the project directory to a directory ~/sync/ on the Vagrant machine ● Make sure that rsync is installed for this to work
  • 12. Vagrant provisioning ● Vagrant provisioning uses the base Box image and applies software installation and configuration updates as an overlay to that ● Provisioners are called from Vagrantfile, using “configvm.provision” ● Different types of provisioners are available, the shell provisioner is the most basic one Vagrant.configure(2) do |config| … Configuration omitted … Config.vm.provision “shell”, inline: <<- SHELL Sudo cp /home/vagrant/sync/etc/yum.repos.d/* /etc/yum.repos.d SHELL … Configuration omitted …
  • 13. Setting up Vagrant with libvirt ● Download vagrant file: https://releases.hashicorp.com/vagrant/2.2.15/vagrant_2.2.15_linux_amd64.zip ● # apt install qemu libvirt-daemon-system libvirt-clients libxslt1-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev ruby-libvirt ebtables dnsmasq-base libguestfs-tools gcc rsync libarchive-tools virt-manager ● # vagrant plugin install vagrant-libvirt ● # vagrant plugin install vagrant-disksize ● # vagrant box add generic/ubuntu2004 --provider libvirt
  • 14. Example ● Create a project directory: ○ # mkdir -p ~/vagrant/test1 ● In this directory, create a Vagrantfile with the following contents ○ Vagrant.configure(“2”) do |config| ○ config.vm.box = “ubuntu/2004” ○ End ● Start VM: # vagrant up [--provider=libvirt] ● Ssh to VM: # vagrant ssh <image> ● Stop VM: # vagrant destroy
  • 16. Understanding Provisioner Types ● The bash provisioner can be used to run shell code ● The ansible provisioner runs Ansible on the Vagrant host ○ Ansible works as control node ○ Vagrant machines work as managed hosts ● The ansible_local provisioner runs Ansible on the Vgrant machines ●
  • 17. Configuring Vagrant for Ansible Provisioning ● The example below shows how the ansible provisioner is used to run the playbook.yml file after deploying the base OS ● Make sure that the playbook.yml is available in the current directory ○ Vagrant.configure (2) do |config| ○ … ○ config.vm.provision “ansible” do | ansible” ○ ansible.playbook = ‘playbook.yml’ ○ end ○ … ○ End ● If you want to run playbooks again without rebuilding VM run: ○ # vagrant provision
  • 19. Understanding Further Integration ● In a development environment, you need code versions to be managed on the Vagrant machine ● Ansible has different source control modules that work with version control software like Git and Subversion ● You can use it, for instance, to populate a web application Document root using the git module in Ansible
  • 20. Ansible Git Example ● … ○ - name: get code ○ git: ○ repo: ssh://user@server1/home/user/git/webapp.git ○ dest: /var/www/html ○ accept_hostkey: yes ● ...
  • 21. Using Forwarded Ports ● To make a deployed application accessible, Vagrant can use forwarded ports ● Forwarded ports map network ports on the host system to ports on the Vagrant machine and thus make it accessible ● Vagrant.configure(2) do |config| ● … ● config.vm.network: forwarded_port, guest: 80, host: 8080 ● end
  • 22. Version Control and IaC ● Place Vagrant + Ansible in a version control system to manage it in an easy way ● Just put the Vagrant project directory in Git to make it happen ● New administrators then just have to use git clone to make the software locally available, followed by vagrant up to recreate the Vagrant development environment ● Just make sure the Git repository has the most recent version of the code ● This solution allows for a clean separation of tasks, where developers take care of code, and operations takes care of new software versions
  • 23. Lab: combining Vagrant and Ansible ● Create a Vagrantfile to install the latest version of ubuntu as a machine with the name lab.example.com ● From the Vagrantfile, call an Ansible playbook that installs the Apache webserver and opens the firewall to allow access to the webserver ● Configure Vagrant port forwarding such that port 8000 on the Vagrant host forwards traffic to the Apache process on the Vagrant installed machine