SlideShare una empresa de Scribd logo
1 de 39
Descargar para leer sin conexión
“Automated Deployment and Configuration
Engines. Ansible”
Alberto Molina Coballes
Teacher at IES Gonzalo Nazareno @alberto_molina
alb.molina@gmail.com
Table of Contents
• Introduction
• Open Source Configuration Management Software:
Puppet, Chef, Salt and Ansible
• Getting started with ansible
• Inventory files, playbooks and modules
• Ansible and docker
• Examples
• Exercises
• References
• Ansible Doc: docs.ansible.com
Server Deployments
Traditional server deployment
• Server provisioning:
• Server acquisition or virtual machine creation
• OS installation and configuration
• Services installation and configuration
• Security settings
• Application Deployment
• Document everything is the key to efficient
troubleshooting
• Expected to live for years
• Scale up (RAM or CPU) implies a server halt
• In server clusters this process is usually automated
with the help of shell scripts
Modern server deployment
• Server provisioning from a base image or template
• Extensive use of configuration management
software:
• OS configuration
• Service installation and configuration
• Security settings
• System upgrades
• Application Deployment from a testing environment,
identical to the production one
• Scale out is preferred over scale up
• Not expected to live for years
Paradigm change (Infrastructure as Code)
Use your infrastructure just as your software:
• Use revision control software like git or
subversion
• Use a good text editor (No, notepad or nano
aren’t) : vim or emacs or even something like
atom or sublime text 2
• Everything must be readable and with comments
• Use a configuration management software
• Devops … What’s that?
Automatic deployment and configuration of short-
lived servers
• Automatic deployment and configuration is an
option using classical servers (virtual or not)
• It becomes mandatory using short-lived servers
• Short-lived servers are common in cloud
computing:
• Scale out
• Variable number of servers depending on
demand
• Automatic deployment and configuration of new
servers is done when needed
• Servers are destroyed if no longer required
Open Source Configuration
Management Software
Configuration Management Software (cms)
• Automation software used for system administrator
tasks
• Standarizes resource configuration and
management:
• Provisioning
• Management
• Release management
• Patch management
• Security
• One example: Heartbleed
Idempotence
“Property of certain operations in mathematics and
computer science, that can be applied multiple
times without changing the result beyond the initial
application”
• Term used in cms to explain the key difference
between them and classical use of shell scripts
• A cms recipe can be safely re-run any number of
times, and at each run it will come to desired state
Example: Idempotence
• Let’s see an example of idempotence on ansible
Chef
• Developed by OpsCode
• Pull architecture: Master server, agents in managed
nodes and a controller node
• Agents are configured to check the master
periodically and apply changes if needed
• Initial release: 2009
• Cookbooks and recipes
• Based on ruby
• Lots of cookbooks available
Puppet
• Developed by Puppet Labs
• Pull architecture
• Initial release: 2005
• Based on ruby
• Uses its own declarative language
• Manifests
• Puppet forge
• Possibly the most widely used
Salt (SaltStack)
• Developed by SaltStack Inc
• Master and minions connected with ZeroMQ
• Initial release: 2011
• Easy to install
• Based on python
• Uses YAML as declarative language and Jinja2 for
templates
Ansible
• Developed by Ansible Inc
• Initial release: 2012
• Push architecture
• Easy to install
• Based on python
• Playboks: Declaration of deployments and
configurations in YAML
• Easy to learn
Chef example: Installing apache2 with chef-solo
# mkdir –p chef/{cookbooks,data_bags,nodes,roles,site-cookbooks}
# cd chef
# git init .
# git submodule add https://github.com/opscode-cookbooks/apt.git cookbooks/apt
# git submodule add https://github.com/opscode-cookbooks/apache2.git
cookbooks/apache2
# git submodule add https://github.com/opscode-cookbooks/iptables.git
cookbooks/iptables
# git submodule add https://github.com/opscode-cookbooks/logrotate.git
cookbooks/logrotate
# echo ‘file_cache_path "/root/chef-solo“’ > solo.rb
# echo ‘cookbook_path "/root/chef-repo/cookbooks“’ >> solo.rb
# echo ‘{ "run_list": [ "recipe[apt]", "recipe[apache2]" ] }’ > web.json
# chef-solo -c solo.rb -j web.json
Puppet example: Installing apache2
• At master, create the file apache2/manifests/init.pp
• Add a webserver node at nodes.pp
class apache2 {
Package[‘apache package’] -> Service[‘apache service’]
package { ‘apache package’:
ensure => installed,
name => “apache2”,
}
service {‘apache service’:
ensure => running,
name => “apache2”,
}
}
node ‘webserver.example.com’ {
include apache2
}
Salt example: Installing apache2
• At master, create the file webservers.sls:
• Initial release: 2012
• Push architecture
• Easy to install
• Apply the formula to one “minion”:
webserver:
pkg:
- installed:
- pkg:
- apache2
# salt ‘webserver1.example.com’ state.sls webserver
Ansible example: Installing apache2
[webservers]
webserver.example.com
---
- name Apache installation
hosts: webservers
tasks:
- name: Ensure apache2 is installed
apt: pkg=apache2
$ ansible-playbook webservers.yml
• Edit inventory file and add the host webserver:
• Edit the file webservers.yml:
• Execute de playbook:
Why ansible?
• Chef and puppet have a significant learning curve
• Small and with few dependences
• Easy to install
• Easy to learn
• Push architecture without agents
• Uses YAML for playbooks and jinja2 for templates
• Very active community
• Closer to typical sysadmin tools
• Salt would be a good option too
Getting started with ansible
Installation
• Software under strong development, packaged
version on your system could be too old
• Available as python package or from github repo
• Installation from pip is very easy:
# apt-get install python-pip python-dev
# pip install ansible
SSH
• Ansible communicates with remote machines over
ssh.
• You need to configure passwordless ssh access to
remote machines
• Exercise: Configure a remote server to access using
ssh public key with passphrase
Inventory files, playbooks
and modules
Inventory files
• INI file with a list of servers
• Servers can be grouped
• Default inventory file is /etc/ansible/hosts
mail.example.com
[webservers]
foo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
Exercises
• Create an inventory file including all servers you
can access using passwordless ssh
• Verify configuration with module ping
$ ansible all –i <inventory file> -m ping
Modules
• Modules can be executed directly on remote hosts
or through Playbooks
• Each module supports taking arguments
• Save this link: Module index
• An example:
$ ansible controller –i <inventory file> -m user –a “name=alberto group=adm”
Playbooks
• Playbooks contains plays
• Each play contains tasks
• Tasks call modules
• Executed sequentially
• Written in YAML (Yet Another Markup Language)
Roadmap
• Ansible is easy to learn, learn it on the job
• Install it, configure the inventory file and practice
• Note: It’s recommended a YAML parser integrated
into your text editor
• When you become familiar with modules:
• Handlers for triggers
• Variables: Jinja2, facts, …
• Conditionals
• Loops
• Roles
• Best practices
Examples
Examples
• https://github.com/ansible/ansible-examples
• https://github.com/openstack-ansible
• https://github.com/albertomolina/Curso-SAD
Ansible and docker
Ansible and docker
• Reference: http://www.ansible.com/docker
Ansible and docker
• With ansible you can manage your docker images
on remote servers
• With ansible you can manage your docker
containers on remote servers
Alternatively
• You can define Dockerfiles that install ansible,
clone a repository and executes an ansible
playbook
Managing docker images with ansible
• Using docker_image module:
• Hosts “web” listed on inventory file and with
docker previously installed and running
• Running this playbook, all the hosts in the group
“web” will have the image “my/app” installed
• docker-py python package is needed
-hosts: web
sudo: yes
tasks:
- name: check or build image
docker_image: path=“Directory with Dockerfile” name=“my/app” 
state=present
Ansible playbooks inside a Dockerfile
• All configuration is done by ansible
• Dockerfile:
FROM ubuntu
MAINTAINER yourname
RUN apt-get -y update
RUN apt-get install -y python-yaml python-jinja2 git
RUN git clone http://github.com/ansible/ansible.git /tmp/ansible
WORKDIR /tmp/ansible
ENV PATH /tmp/ansible/bin:/sbin:/usr/sbin:/usr/bin
ENV ANSIBLE_LIBRARY /tmp/ansible/library
ENV PYTHONPATH /tmp/ansible/lib:$PYTHON_PATH
RUN git clone http://github.com/yourusername/yourrepo.git /tmp/example
ADD inventory /etc/ansible/hosts
WORKDIR /tmp/examples
RUN ansible-playbook site.yml -c local
EXPOSE 22 3000
ENTRYPOINT [“/usr/bin/foo”]
Exercises
Exercises
1. Create a playbook for for install nginx on Debian
or Ubuntu
2. Create a playbook for the LAMP stack
3. Deploy a minimal PHP application
4. Docker:
1. Build with ansible a minimal docker image with
nginx using the Dockerfile example from last
session
2. Start with ansible a container based on last
image
3. Create a Dockerfile to call an ansible playbook
that installs nginx. Build it with docker
command
Thanks
Alberto Molina Coballes
Teacher at IES Gonzalo Nazareno @alberto_molina
alb.molina@gmail.com

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
 
Monitor-Driven Development Using Ansible
Monitor-Driven Development Using AnsibleMonitor-Driven Development Using Ansible
Monitor-Driven Development Using Ansible
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
 
Introduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen SummitIntroduction to Chef - Techsuperwomen Summit
Introduction to Chef - Techsuperwomen Summit
 
Ansible Devops North East - slides
Ansible Devops North East - slides Ansible Devops North East - slides
Ansible Devops North East - slides
 
Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015Introduction to Chef - April 22 2015
Introduction to Chef - April 22 2015
 
Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
Infrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & AnsibleInfrastructure Automation with Chef & Ansible
Infrastructure Automation with Chef & Ansible
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
 
Ansible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL MeetupAnsible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL Meetup
 
CIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef CookbooksCIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
CIRCUIT 2015 - AEM Infrastructure Automation with Chef Cookbooks
 
Docker
DockerDocker
Docker
 
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
 
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & TomorrowTXLF: Chef- Software Defined Infrastructure Today & Tomorrow
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3
 
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsChasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
 

Destacado

MultiCloud Bursting from Openstack to Windows Azure and Amazon AWS with Righ...
 MultiCloud Bursting from Openstack to Windows Azure and Amazon AWS with Righ... MultiCloud Bursting from Openstack to Windows Azure and Amazon AWS with Righ...
MultiCloud Bursting from Openstack to Windows Azure and Amazon AWS with Righ...
bn-cloud
 
Project specification btec level 2 digital install
Project specification btec level 2 digital installProject specification btec level 2 digital install
Project specification btec level 2 digital install
NINANC
 
Client briefing notes
Client briefing notesClient briefing notes
Client briefing notes
NINANC
 
Seminar on excellence in ict enhanced higher education sequent2014
Seminar on excellence in ict enhanced higher education sequent2014Seminar on excellence in ict enhanced higher education sequent2014
Seminar on excellence in ict enhanced higher education sequent2014
Ebba Ossiannilsson
 

Destacado (20)

Integracion Openstack VMware
Integracion Openstack VMwareIntegracion Openstack VMware
Integracion Openstack VMware
 
MultiCloud Bursting from Openstack to Windows Azure and Amazon AWS with Righ...
 MultiCloud Bursting from Openstack to Windows Azure and Amazon AWS with Righ... MultiCloud Bursting from Openstack to Windows Azure and Amazon AWS with Righ...
MultiCloud Bursting from Openstack to Windows Azure and Amazon AWS with Righ...
 
Leru ossiannlisson oxford120313
Leru ossiannlisson oxford120313Leru ossiannlisson oxford120313
Leru ossiannlisson oxford120313
 
Own cloudusermanual
Own cloudusermanualOwn cloudusermanual
Own cloudusermanual
 
Citizen shift social_media_ecole-ete-2010_final
Citizen shift social_media_ecole-ete-2010_finalCitizen shift social_media_ecole-ete-2010_final
Citizen shift social_media_ecole-ete-2010_final
 
Project specification btec level 2 digital install
Project specification btec level 2 digital installProject specification btec level 2 digital install
Project specification btec level 2 digital install
 
РИФ 2016, Будет ли это next big thing или это просто hipe?
РИФ 2016, Будет ли это next big thing или это просто hipe?РИФ 2016, Будет ли это next big thing или это просто hipe?
РИФ 2016, Будет ли это next big thing или это просто hipe?
 
Icde ossiannlisson oer_oct2011
Icde ossiannlisson oer_oct2011Icde ossiannlisson oer_oct2011
Icde ossiannlisson oer_oct2011
 
Ossiannilsson oei2 berlin_7_sept2015
Ossiannilsson oei2 berlin_7_sept2015Ossiannilsson oei2 berlin_7_sept2015
Ossiannilsson oei2 berlin_7_sept2015
 
РИФ 2016, Ошибки зарубежных компаний при выходе на российский рынок
РИФ 2016, Ошибки зарубежных компаний при выходе на российский рынокРИФ 2016, Ошибки зарубежных компаний при выходе на российский рынок
РИФ 2016, Ошибки зарубежных компаний при выходе на российский рынок
 
Social media in education
Social media in educationSocial media in education
Social media in education
 
Ossiannilsson eucen november2016 [sparad automatiskt]
Ossiannilsson eucen november2016 [sparad automatiskt]Ossiannilsson eucen november2016 [sparad automatiskt]
Ossiannilsson eucen november2016 [sparad automatiskt]
 
Culture Bm V2
Culture Bm V2Culture Bm V2
Culture Bm V2
 
Sade icde operational network nordic and baltic countries
Sade icde operational network nordic and baltic countriesSade icde operational network nordic and baltic countries
Sade icde operational network nordic and baltic countries
 
Client briefing notes
Client briefing notesClient briefing notes
Client briefing notes
 
Seminar on excellence in ict enhanced higher education sequent2014
Seminar on excellence in ict enhanced higher education sequent2014Seminar on excellence in ict enhanced higher education sequent2014
Seminar on excellence in ict enhanced higher education sequent2014
 
Frisse Wind
Frisse WindFrisse Wind
Frisse Wind
 
Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15
Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15
Ossiannilsson ec et2020_wgdol_ljubliana_moo_cs_oer15_09_15
 
РИФ 2016, Умри завтра или сегментируй сегодня
РИФ 2016, Умри завтра или сегментируй сегодняРИФ 2016, Умри завтра или сегментируй сегодня
РИФ 2016, Умри завтра или сегментируй сегодня
 
РИФ 2016, НЕкорпоративный портал
РИФ 2016, НЕкорпоративный порталРИФ 2016, НЕкорпоративный портал
РИФ 2016, НЕкорпоративный портал
 

Similar a Automated Deployment and Configuration Engines. Ansible

Similar a Automated Deployment and Configuration Engines. Ansible (20)

Power of Azure Devops
Power of Azure DevopsPower of Azure Devops
Power of Azure Devops
 
Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack Summit
 
Hosting a Rails App
Hosting a Rails AppHosting a Rails App
Hosting a Rails App
 
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
 
OSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy HawkinsOSDC 2013 | Introduction into Chef by Andy Hawkins
OSDC 2013 | Introduction into Chef by Andy Hawkins
 
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
 
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
 
CI/CD with Azure DevOps and Azure Databricks
CI/CD with Azure DevOps and Azure DatabricksCI/CD with Azure DevOps and Azure Databricks
CI/CD with Azure DevOps and Azure Databricks
 
No Docker? No Problem: Automating installation and config with Ansible
No Docker? No Problem: Automating installation and config with AnsibleNo Docker? No Problem: Automating installation and config with Ansible
No Docker? No Problem: Automating installation and config with Ansible
 
Cloudsolutionday 2016: DevOps workflow with Docker on AWS
Cloudsolutionday 2016: DevOps workflow with Docker on AWSCloudsolutionday 2016: DevOps workflow with Docker on AWS
Cloudsolutionday 2016: DevOps workflow with Docker on AWS
 
A Million ways of Deploying a Kubernetes Cluster
A Million ways of Deploying a Kubernetes ClusterA Million ways of Deploying a Kubernetes Cluster
A Million ways of Deploying a Kubernetes Cluster
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
Ansible Tutorial.pdf
Ansible Tutorial.pdfAnsible Tutorial.pdf
Ansible Tutorial.pdf
 
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
 
Agiles Peru 2019 - Infrastructure As Code
Agiles Peru 2019 - Infrastructure As CodeAgiles Peru 2019 - Infrastructure As Code
Agiles Peru 2019 - Infrastructure As Code
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and Packer
 
Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable Infrastructure
 
Devops
DevopsDevops
Devops
 
Preparing your dockerised application for production deployment
Preparing your dockerised application for production deploymentPreparing your dockerised application for production deployment
Preparing your dockerised application for production deployment
 
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and WindowsOpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
 

Más de Alberto Molina Coballes (8)

Open stack 5th birthday slide deck
Open stack 5th birthday slide deckOpen stack 5th birthday slide deck
Open stack 5th birthday slide deck
 
Bitnami Bootcamp. OpenStack
Bitnami Bootcamp. OpenStackBitnami Bootcamp. OpenStack
Bitnami Bootcamp. OpenStack
 
Despliegue de un Cloud privado de IaaS con fines educativos utilizando softwa...
Despliegue de un Cloud privado de IaaS con fines educativos utilizando softwa...Despliegue de un Cloud privado de IaaS con fines educativos utilizando softwa...
Despliegue de un Cloud privado de IaaS con fines educativos utilizando softwa...
 
Iaas en las enseñanzas de informática
Iaas en las enseñanzas de informáticaIaas en las enseñanzas de informática
Iaas en las enseñanzas de informática
 
Introducción a OpenStak Horizon
Introducción a OpenStak HorizonIntroducción a OpenStak Horizon
Introducción a OpenStak Horizon
 
Intro gnu-linux
Intro gnu-linuxIntro gnu-linux
Intro gnu-linux
 
Servicios web
Servicios webServicios web
Servicios web
 
Software libre: Situación actual y oportunidades laborales
Software libre: Situación actual y oportunidades laboralesSoftware libre: Situación actual y oportunidades laborales
Software libre: Situación actual y oportunidades laborales
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Automated Deployment and Configuration Engines. Ansible

  • 1. “Automated Deployment and Configuration Engines. Ansible” Alberto Molina Coballes Teacher at IES Gonzalo Nazareno @alberto_molina alb.molina@gmail.com
  • 2. Table of Contents • Introduction • Open Source Configuration Management Software: Puppet, Chef, Salt and Ansible • Getting started with ansible • Inventory files, playbooks and modules • Ansible and docker • Examples • Exercises • References • Ansible Doc: docs.ansible.com
  • 4. Traditional server deployment • Server provisioning: • Server acquisition or virtual machine creation • OS installation and configuration • Services installation and configuration • Security settings • Application Deployment • Document everything is the key to efficient troubleshooting • Expected to live for years • Scale up (RAM or CPU) implies a server halt • In server clusters this process is usually automated with the help of shell scripts
  • 5. Modern server deployment • Server provisioning from a base image or template • Extensive use of configuration management software: • OS configuration • Service installation and configuration • Security settings • System upgrades • Application Deployment from a testing environment, identical to the production one • Scale out is preferred over scale up • Not expected to live for years
  • 6. Paradigm change (Infrastructure as Code) Use your infrastructure just as your software: • Use revision control software like git or subversion • Use a good text editor (No, notepad or nano aren’t) : vim or emacs or even something like atom or sublime text 2 • Everything must be readable and with comments • Use a configuration management software • Devops … What’s that?
  • 7. Automatic deployment and configuration of short- lived servers • Automatic deployment and configuration is an option using classical servers (virtual or not) • It becomes mandatory using short-lived servers • Short-lived servers are common in cloud computing: • Scale out • Variable number of servers depending on demand • Automatic deployment and configuration of new servers is done when needed • Servers are destroyed if no longer required
  • 9. Configuration Management Software (cms) • Automation software used for system administrator tasks • Standarizes resource configuration and management: • Provisioning • Management • Release management • Patch management • Security • One example: Heartbleed
  • 10. Idempotence “Property of certain operations in mathematics and computer science, that can be applied multiple times without changing the result beyond the initial application” • Term used in cms to explain the key difference between them and classical use of shell scripts • A cms recipe can be safely re-run any number of times, and at each run it will come to desired state
  • 11. Example: Idempotence • Let’s see an example of idempotence on ansible
  • 12. Chef • Developed by OpsCode • Pull architecture: Master server, agents in managed nodes and a controller node • Agents are configured to check the master periodically and apply changes if needed • Initial release: 2009 • Cookbooks and recipes • Based on ruby • Lots of cookbooks available
  • 13. Puppet • Developed by Puppet Labs • Pull architecture • Initial release: 2005 • Based on ruby • Uses its own declarative language • Manifests • Puppet forge • Possibly the most widely used
  • 14. Salt (SaltStack) • Developed by SaltStack Inc • Master and minions connected with ZeroMQ • Initial release: 2011 • Easy to install • Based on python • Uses YAML as declarative language and Jinja2 for templates
  • 15. Ansible • Developed by Ansible Inc • Initial release: 2012 • Push architecture • Easy to install • Based on python • Playboks: Declaration of deployments and configurations in YAML • Easy to learn
  • 16. Chef example: Installing apache2 with chef-solo # mkdir –p chef/{cookbooks,data_bags,nodes,roles,site-cookbooks} # cd chef # git init . # git submodule add https://github.com/opscode-cookbooks/apt.git cookbooks/apt # git submodule add https://github.com/opscode-cookbooks/apache2.git cookbooks/apache2 # git submodule add https://github.com/opscode-cookbooks/iptables.git cookbooks/iptables # git submodule add https://github.com/opscode-cookbooks/logrotate.git cookbooks/logrotate # echo ‘file_cache_path "/root/chef-solo“’ > solo.rb # echo ‘cookbook_path "/root/chef-repo/cookbooks“’ >> solo.rb # echo ‘{ "run_list": [ "recipe[apt]", "recipe[apache2]" ] }’ > web.json # chef-solo -c solo.rb -j web.json
  • 17. Puppet example: Installing apache2 • At master, create the file apache2/manifests/init.pp • Add a webserver node at nodes.pp class apache2 { Package[‘apache package’] -> Service[‘apache service’] package { ‘apache package’: ensure => installed, name => “apache2”, } service {‘apache service’: ensure => running, name => “apache2”, } } node ‘webserver.example.com’ { include apache2 }
  • 18. Salt example: Installing apache2 • At master, create the file webservers.sls: • Initial release: 2012 • Push architecture • Easy to install • Apply the formula to one “minion”: webserver: pkg: - installed: - pkg: - apache2 # salt ‘webserver1.example.com’ state.sls webserver
  • 19. Ansible example: Installing apache2 [webservers] webserver.example.com --- - name Apache installation hosts: webservers tasks: - name: Ensure apache2 is installed apt: pkg=apache2 $ ansible-playbook webservers.yml • Edit inventory file and add the host webserver: • Edit the file webservers.yml: • Execute de playbook:
  • 20. Why ansible? • Chef and puppet have a significant learning curve • Small and with few dependences • Easy to install • Easy to learn • Push architecture without agents • Uses YAML for playbooks and jinja2 for templates • Very active community • Closer to typical sysadmin tools • Salt would be a good option too
  • 22. Installation • Software under strong development, packaged version on your system could be too old • Available as python package or from github repo • Installation from pip is very easy: # apt-get install python-pip python-dev # pip install ansible
  • 23. SSH • Ansible communicates with remote machines over ssh. • You need to configure passwordless ssh access to remote machines • Exercise: Configure a remote server to access using ssh public key with passphrase
  • 25. Inventory files • INI file with a list of servers • Servers can be grouped • Default inventory file is /etc/ansible/hosts mail.example.com [webservers] foo.example.com bar.example.com [dbservers] one.example.com two.example.com three.example.com
  • 26. Exercises • Create an inventory file including all servers you can access using passwordless ssh • Verify configuration with module ping $ ansible all –i <inventory file> -m ping
  • 27. Modules • Modules can be executed directly on remote hosts or through Playbooks • Each module supports taking arguments • Save this link: Module index • An example: $ ansible controller –i <inventory file> -m user –a “name=alberto group=adm”
  • 28. Playbooks • Playbooks contains plays • Each play contains tasks • Tasks call modules • Executed sequentially • Written in YAML (Yet Another Markup Language)
  • 29. Roadmap • Ansible is easy to learn, learn it on the job • Install it, configure the inventory file and practice • Note: It’s recommended a YAML parser integrated into your text editor • When you become familiar with modules: • Handlers for triggers • Variables: Jinja2, facts, … • Conditionals • Loops • Roles • Best practices
  • 33. Ansible and docker • Reference: http://www.ansible.com/docker
  • 34. Ansible and docker • With ansible you can manage your docker images on remote servers • With ansible you can manage your docker containers on remote servers Alternatively • You can define Dockerfiles that install ansible, clone a repository and executes an ansible playbook
  • 35. Managing docker images with ansible • Using docker_image module: • Hosts “web” listed on inventory file and with docker previously installed and running • Running this playbook, all the hosts in the group “web” will have the image “my/app” installed • docker-py python package is needed -hosts: web sudo: yes tasks: - name: check or build image docker_image: path=“Directory with Dockerfile” name=“my/app” state=present
  • 36. Ansible playbooks inside a Dockerfile • All configuration is done by ansible • Dockerfile: FROM ubuntu MAINTAINER yourname RUN apt-get -y update RUN apt-get install -y python-yaml python-jinja2 git RUN git clone http://github.com/ansible/ansible.git /tmp/ansible WORKDIR /tmp/ansible ENV PATH /tmp/ansible/bin:/sbin:/usr/sbin:/usr/bin ENV ANSIBLE_LIBRARY /tmp/ansible/library ENV PYTHONPATH /tmp/ansible/lib:$PYTHON_PATH RUN git clone http://github.com/yourusername/yourrepo.git /tmp/example ADD inventory /etc/ansible/hosts WORKDIR /tmp/examples RUN ansible-playbook site.yml -c local EXPOSE 22 3000 ENTRYPOINT [“/usr/bin/foo”]
  • 38. Exercises 1. Create a playbook for for install nginx on Debian or Ubuntu 2. Create a playbook for the LAMP stack 3. Deploy a minimal PHP application 4. Docker: 1. Build with ansible a minimal docker image with nginx using the Dockerfile example from last session 2. Start with ansible a container based on last image 3. Create a Dockerfile to call an ansible playbook that installs nginx. Build it with docker command
  • 39. Thanks Alberto Molina Coballes Teacher at IES Gonzalo Nazareno @alberto_molina alb.molina@gmail.com