SlideShare a Scribd company logo
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 ansible
Khizer Naeem
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
Dan Vaida
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
bcoca
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102
APNIC
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
Arthur Freyman
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
laonap166
 
Ansible 202 - sysarmy
Ansible 202 - sysarmyAnsible 202 - sysarmy
Ansible 202 - sysarmy
Sebastian Montini
 
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
Alex S
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
Tim Fairweather
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
CorkOpenTech
 
Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy Mykhailiuta
Tetiana 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
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
Bangladesh Network Operators Group
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetup
Greg DeKoenigsberg
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
Kumar Y
 
Development of Ansible modules
Development of Ansible modulesDevelopment of Ansible modules
Development of Ansible modules
jtyr
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
bcoca
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
John Lynch
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
CoreStack
 
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
ansiblebrno
 

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 - 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
 
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
 
Vagrant 101 Workshop
Vagrant 101 WorkshopVagrant 101 Workshop
Vagrant 101 Workshop
Liora Milbaum
 
Magento Docker Setup.pdf
Magento Docker Setup.pdfMagento Docker Setup.pdf
Magento Docker Setup.pdf
Abid 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 2016
David 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 @ Benetech
Christopher Bumgardner
 
Varying wordpressdevelopmentenvironment wp-campus2016
Varying wordpressdevelopmentenvironment wp-campus2016Varying wordpressdevelopmentenvironment wp-campus2016
Varying wordpressdevelopmentenvironment wp-campus2016
David Brattoli
 
Development with Vagrant
Development with VagrantDevelopment with Vagrant
Development with Vagrant
John 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 Worksheets
Darrel Chia
 
Vagrantfordevops
VagrantfordevopsVagrantfordevops
Vagrantfordevops
Deepanshu Gajbhiye
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013
Hendrik 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 Wood
Ortus Solutions, Corp
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized Development
Adam Culp
 
Ansible & Vagrant
Ansible & VagrantAnsible & Vagrant
Ansible & Vagrant
Mukul Malhotra
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John 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 2016
David Brattoli
 
Vagrant workshop 2015
Vagrant workshop 2015Vagrant workshop 2015
Vagrant workshop 2015
Haifa Ftirich
 

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

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....
 
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
 
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

A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
Ratnakar Mikkili
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 

Recently uploaded (20)

A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.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