SlideShare a Scribd company logo
1 of 44
Download to read offline
ZERO DOWNTIME DEPLOYMENT WITH ANSIBLE 
OPEN
SLIDES & REPO 
http://steinim.github.io/slides/zero-downtime-ansible 
https://github.com/steinim/zero-downtime-ansible
WHAT'S A PROVISIONING FRAMEWORK? 
Automated setup of servers 
Configuration as code
EXAMPLES 
Create users 
Install software 
Generate and manipulate config files 
Start/stop/restart processes 
Set up dependencies between operations
DESCRIBE WHAT TO DO 
#!/bin/bash 
if $( command -v vim >/dev/null 2>&1 ); then 
echo "vim is already installed." 
else 
apt-get install vim 
fi 
if $( grep -Fxq "filetype indent off" /etc/vim/vimrc ); then 
echo "set filetype indent off is already in /etc/vim/vimrc." 
else 
echo "filetype indent off" >> /etc/vim/vimrc 
# TODO: Do not continue if this fails. 
fi 
# TODO: Rollback if something fails.
DESCRIBE STATE 
- name: ensure installed vim 
apt: pkg=vim state=installed 
- name: set filetype indent off for vim 
lineinfile: 
dest=/etc/vim/vimrc 
line='filetype indent off' 
state=present
ANSIBLE 
SSH-based 
Client only (no server) 
YAML configuration 
Push (and pull) 
Supports more than setup and provisioning: 
Application deployment 
Remote command execution
BRING UP THE BOXES 
vagrant up
LAYOUT 
├── ansible.cfg 
├── hosts 
├── site.yml 
├── group_vars 
│ └── <group name> 
├── host_vars 
│ └── <host name> 
├── roles 
│ ├── <role> 
│ │ ├── files 
│ │ └── <file> 
│ │ └── templates 
│ │ └── <template>.j2 
│ │ ├── handlers 
│ │ │ └── main.yml 
│ │ ├── tasks 
│ │ │ └── main.yml
PLAY! 
ansible-playbook site.yml
FACTS 
Ansible by default gathers “facts” about the machines under 
management. 
These facts can be accessed in Playbooks and in templates. 
ansible -m setup app1.local
THE TASK 
An app user 'devops', with: 
Home directory: /home/devops 
ssh-key 
A PostgresSQL database. 
Nginx as a reverse proxy. 
An init script installed as a service. 
Deploy an application that uses the provisioned infrastructure.
HELP! 
http://docs.ansible.com/list_of_all_modules.html
TASK1: INSTALL AND CONFIGURE SOFTWARE 
git checkout start 
Modify roles/common/tasks/apt.yml. 
Install Vim. 
Insert the line 'filetype indent off' in /etc/vim/vimrc 
Help: 
http://docs.ansible.com/apt_module.html 
http://docs.ansible.com/lineinfile_module.html 
git checkout task1_help
TASK1: SOLUTION 
git diff HEAD origin/task1 
git checkout task1 # or keep your own solution 
ansible-playbook site.yml --tags apt,vim 
ProTip: Use '--tags', '--skip-tags', '--limit' and/or 'gather_facts: False' 
to reduce execution time.
PROGRESS 
Installed software 
Manipulated files
VARIABLES 
Ansible uses variables (a lot!). 
Inventory 
group_vars and host_vars 
Playbook 
Facts 
Command line 
Access variables from playbooks: "{{ variable }}" 
http://docs.ansible.com/playbooks_variables.html
TASK2: CREATE AN APPLICATION USER 
Create roles/users/tasks/main.yml 
Home directory: /home/devops 
ssh-key 
Use variables! (group_vars) 
Help: 
http://docs.ansible.com/group_module.html 
http://docs.ansible.com/user_module.html 
http://docs.ansible.com/file_module.html 
(copy ssh-key) 
http://docs.ansible.com/lineinfile_module.html 
(.ssh/authorized_keys) 
http://docs.ansible.com/playbooks_best_practices.html#group-and-host-variables 
git checkout task2_help
TASK2: SOLUTION 
git diff HEAD origin/task2 
git checkout task2 # or keep your own solution 
ansible-playbook site.yml --limit appservers --skip-tags apt,vim,java 
ssh devops@app1.local
PROGRESS 
Installed software 
Manipulated files 
Created a user and set up a ssh-key
TASK3: INSTALL AND CONFIGURE POSTGRESQL 
roles/postgresql 
├── files 
│ ├── ACCC4CF8.asc 
│ └── postgresql.conf 
├── handlers 
│ └── main.yml 
├── tasks 
│ ├── main.yml 
│ └── ... 
└── templates 
└── pg_hba.conf.j2 
Use variables (group_vars/all and/or group_vars/dbservers). 
Use handler to restart postgresql upon notification 
Template: git checkout master -- roles/postgresql/templates/pg_hba.conf.j2 
Help: 
http://docs.ansible.com/template_module.html 
(pg_hba.conf.j2) 
http://docs.ansible.com/postgresql_user_module.html 
http://docs.ansible.com/postgresql_db_module.html 
http://docs.ansible.com/playbooks_intro.html#handlers-running-operations-on-change 
http://docs.ansible.com/playbooks_best_practices.html#group-and-host-variables
TASK3: SOLUTION 
git diff HEAD origin/task3 
git checkout task3 # or keep your own solution 
ansible-playbook site.yml --limit dbservers --tags pg_install 
$ vagrant ssh db 
vagrant@db:~$ psql -d devops -U devops -W 
devops=> q
PROGRESS 
Installed software 
Manipulated files 
Created a user and set up a ssh-key 
Installed and configured a database and a db user
TASK4: DEPLOY! 
roles/app 
├── files 
│ └── init.sh 
├── tasks 
│ └── main.yml 
└── templates 
└── config.properties.j2 
NB! Use variables (./hosts). 
Set 'serial: 1' for appservers in site.yml. 
Help: 
http://docs.ansible.com/service_module.html
TASK4: SOLUTION 
Browse to http://app1.local:1234/ 
git diff HEAD origin/task4 
git checkout task4 # or keep your own solution 
ansible-playbook site.yml --limit appservers --tags deploy
WHAT JUST HAPPENED? 
/home/devops 
├── config.properties 
├── current -> /home/devops/devops_1416228023.jar 
├── previous -> /home/devops/devops_1416221573.jar 
├── devops_1416221573.jar 
├── devops_1416228023.jar 
└── logs 
├── stderr.log 
└── stdout.log 
/etc/init.d 
└── devops
PROGRESS 
Installed software 
Manipulated files 
Created a user and set up a ssh-key 
Installed and configured a database and a db user 
Deployed an application to two appservers and enabled it as a 
service
TASK5: DEPLOY DATABASE 
roles/db 
├── files 
│ └── migrate_db.sql 
└── tasks 
└── main.yml 
Help: 
http://docs.ansible.com/command_module.html 
psql -d {{ db.name }} -q -f /tmp/migrate_db.sql 
sudo_user: postgres
TASK5: SOLUTION 
Browse to http://app1.local:1234/ 
git diff HEAD origin/task5 
git checkout task5 # or keep your own solution 
ansible-playbook site.yml --limit dbservers --tags deploy 
$ vagrant ssh db 
vagrant@db:~$ psql -d devops -U devops -W 
devops=> dt 
devops=> select * from hello; 
devops=> q
PROGRESS 
Installed software 
Manipulated files 
Created a user and set up a ssh-key 
Installed and configured a database and a db user 
Deployed an application to two appservers and enabled it as a 
service 
Migrated the database schema and fetched data from it through the 
application
TASK6: SET UP PROXY 
roles/nginx 
├── handlers 
│ └── main.yml 
├── tasks 
│ ├── config_nginx.yml 
│ ├── install_nginx.yml 
│ └── main.yml 
└── templates 
└── devops.conf.j2 
Help: 
http://wsgiarea.pocoo.org/jinja/docs/loops.html
TASK6: SOLUTION 
Browse to # refresh http://proxy.local/ me many times 
git diff HEAD origin/task6 
git checkout task6 # or keep your own solution 
ansible-playbook site.yml --limit proxies --tags nginx
PROGRESS 
Installed software 
Manipulated files 
Created a user and set up a ssh-key 
Installed and configured a database and a db user 
Deployed an application to two appservers and enabled it as a 
service 
Migrated the database schema and fetched data from it through the 
application 
Set up a reverse proxy for automatic failover between the two 
appservers
THE EXPAND/CONTRACT PATTERN 
Expand Contract 
Add tables 
Add columns 
Tweak indexes 
Remove tables 
Remove columns 
Remove/add constraints
PLAY TIME :-) 
Suggestions: 
Change database table name from HELLO to MESSAGES and 
deploy a new version without downtime. 
Implement automated rollback.
I HAVE BEEN PLAYING :-) 
git checkout play 
ansible-playbook site.yml --limit appservers,dbservers --tags deploy 
ansible-playbook site.yml --limit appservers,dbservers --tags rollback
THANK YOU! 
@steinim 
stein.inge.morisbak@BEKK.no

More Related Content

What's hot

Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點William Yeh
 
10 Million hits a day with WordPress using a $15 VPS
10 Million hits a day  with WordPress using a $15 VPS10 Million hits a day  with WordPress using a $15 VPS
10 Million hits a day with WordPress using a $15 VPSPaolo Tonin
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)Soshi Nemoto
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!Derek Willian Stavis
 
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014Puppet
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
The Challenges of Container Configuration
The Challenges of Container ConfigurationThe Challenges of Container Configuration
The Challenges of Container ConfigurationGareth Rushgrove
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Soshi Nemoto
 
Frontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeFrontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeDamien Seguin
 
CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)Soshi Nemoto
 
Django deployment best practices
Django deployment best practicesDjango deployment best practices
Django deployment best practicesErik LaBianca
 
Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014Puppet
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year laterChristian Ortner
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Puppet
 
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerOrtus Solutions, Corp
 
Zero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudZero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudJames Heggs
 
Instruction: dev environment
Instruction: dev environmentInstruction: dev environment
Instruction: dev environmentSoshi Nemoto
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile InfrastructuresAntons Kranga
 
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Julian Dunn
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Łukasz Proszek
 

What's hot (20)

Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點
 
10 Million hits a day with WordPress using a $15 VPS
10 Million hits a day  with WordPress using a $15 VPS10 Million hits a day  with WordPress using a $15 VPS
10 Million hits a day with WordPress using a $15 VPS
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!
 
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
The Challenges of Container Configuration
The Challenges of Container ConfigurationThe Challenges of Container Configuration
The Challenges of Container Configuration
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)
 
Frontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeFrontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the like
 
CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)
 
Django deployment best practices
Django deployment best practicesDjango deployment best practices
Django deployment best practices
 
Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014Test Driven Development with Puppet - PuppetConf 2014
Test Driven Development with Puppet - PuppetConf 2014
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
 
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and docker
 
Zero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudZero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google Cloud
 
Instruction: dev environment
Instruction: dev environmentInstruction: dev environment
Instruction: dev environment
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
 
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.
 

Viewers also liked

Continuous Delivery and Zero Downtime
Continuous Delivery and Zero DowntimeContinuous Delivery and Zero Downtime
Continuous Delivery and Zero DowntimeAxel Fontaine
 
Moving Towards Zero Downtime
Moving Towards Zero DowntimeMoving Towards Zero Downtime
Moving Towards Zero DowntimeBCM Institute
 
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesAlexander Penev
 
Roadshow presentation 2012
Roadshow presentation 2012Roadshow presentation 2012
Roadshow presentation 2012bluebuilding
 
Компьютерные курсы для пожилых людей. Занятия 1 4
Компьютерные курсы для пожилых людей. Занятия 1 4Компьютерные курсы для пожилых людей. Занятия 1 4
Компьютерные курсы для пожилых людей. Занятия 1 4Ilya Novikov
 
20 Tips to Improve Your Government Career - From Networking to Branding and More
20 Tips to Improve Your Government Career - From Networking to Branding and More20 Tips to Improve Your Government Career - From Networking to Branding and More
20 Tips to Improve Your Government Career - From Networking to Branding and MoreSteve Ressler
 
Presentation Pablo Ruiz Bangkok 2012
Presentation Pablo Ruiz Bangkok 2012Presentation Pablo Ruiz Bangkok 2012
Presentation Pablo Ruiz Bangkok 2012Pablo Ruiz Amo
 
The new new new thing
The new new new thingThe new new new thing
The new new new thingSimon Jones
 
How to Build the Perfect LinkedIn Profile
How to Build the Perfect LinkedIn ProfileHow to Build the Perfect LinkedIn Profile
How to Build the Perfect LinkedIn ProfileCara Barone
 
Zombie Lead Hunter Webinar: How to immunize your lead management from zombie ...
Zombie Lead Hunter Webinar: How to immunize your lead management from zombie ...Zombie Lead Hunter Webinar: How to immunize your lead management from zombie ...
Zombie Lead Hunter Webinar: How to immunize your lead management from zombie ...MarketStar Corp
 
Projeto prnto para o blog
Projeto prnto para o blogProjeto prnto para o blog
Projeto prnto para o blogDiego Mendes
 
Acre test and catholic schools
Acre test and catholic schoolsAcre test and catholic schools
Acre test and catholic schoolsmarmartin6
 
Présentation Gradle au LyonJUG par Grégory Boissinot - Zenika
Présentation Gradle au LyonJUG par Grégory Boissinot - ZenikaPrésentation Gradle au LyonJUG par Grégory Boissinot - Zenika
Présentation Gradle au LyonJUG par Grégory Boissinot - ZenikaZenika
 
06 mark hindmarsh csl guidance.ppt
06  mark hindmarsh csl guidance.ppt06  mark hindmarsh csl guidance.ppt
06 mark hindmarsh csl guidance.pptbluebuilding
 
20091109 EC Gaal Broadcasting Tvi
20091109 EC Gaal Broadcasting Tvi20091109 EC Gaal Broadcasting Tvi
20091109 EC Gaal Broadcasting Tvigaalnorb
 
fisiogramas
fisiogramasfisiogramas
fisiogramasmulanci
 

Viewers also liked (20)

Continuous Delivery and Zero Downtime
Continuous Delivery and Zero DowntimeContinuous Delivery and Zero Downtime
Continuous Delivery and Zero Downtime
 
Moving Towards Zero Downtime
Moving Towards Zero DowntimeMoving Towards Zero Downtime
Moving Towards Zero Downtime
 
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE Architectures
 
Roadshow presentation 2012
Roadshow presentation 2012Roadshow presentation 2012
Roadshow presentation 2012
 
Palestraconatedu
PalestraconateduPalestraconatedu
Palestraconatedu
 
Компьютерные курсы для пожилых людей. Занятия 1 4
Компьютерные курсы для пожилых людей. Занятия 1 4Компьютерные курсы для пожилых людей. Занятия 1 4
Компьютерные курсы для пожилых людей. Занятия 1 4
 
20 Tips to Improve Your Government Career - From Networking to Branding and More
20 Tips to Improve Your Government Career - From Networking to Branding and More20 Tips to Improve Your Government Career - From Networking to Branding and More
20 Tips to Improve Your Government Career - From Networking to Branding and More
 
Presentation Pablo Ruiz Bangkok 2012
Presentation Pablo Ruiz Bangkok 2012Presentation Pablo Ruiz Bangkok 2012
Presentation Pablo Ruiz Bangkok 2012
 
The new new new thing
The new new new thingThe new new new thing
The new new new thing
 
How to Build the Perfect LinkedIn Profile
How to Build the Perfect LinkedIn ProfileHow to Build the Perfect LinkedIn Profile
How to Build the Perfect LinkedIn Profile
 
Zombie Lead Hunter Webinar: How to immunize your lead management from zombie ...
Zombie Lead Hunter Webinar: How to immunize your lead management from zombie ...Zombie Lead Hunter Webinar: How to immunize your lead management from zombie ...
Zombie Lead Hunter Webinar: How to immunize your lead management from zombie ...
 
Projeto prnto para o blog
Projeto prnto para o blogProjeto prnto para o blog
Projeto prnto para o blog
 
Emeief prof
Emeief profEmeief prof
Emeief prof
 
55555
5555555555
55555
 
Acre test and catholic schools
Acre test and catholic schoolsAcre test and catholic schools
Acre test and catholic schools
 
Présentation Gradle au LyonJUG par Grégory Boissinot - Zenika
Présentation Gradle au LyonJUG par Grégory Boissinot - ZenikaPrésentation Gradle au LyonJUG par Grégory Boissinot - Zenika
Présentation Gradle au LyonJUG par Grégory Boissinot - Zenika
 
Lousa Digital
Lousa DigitalLousa Digital
Lousa Digital
 
06 mark hindmarsh csl guidance.ppt
06  mark hindmarsh csl guidance.ppt06  mark hindmarsh csl guidance.ppt
06 mark hindmarsh csl guidance.ppt
 
20091109 EC Gaal Broadcasting Tvi
20091109 EC Gaal Broadcasting Tvi20091109 EC Gaal Broadcasting Tvi
20091109 EC Gaal Broadcasting Tvi
 
fisiogramas
fisiogramasfisiogramas
fisiogramas
 

Similar to Zero Downtime Deployment with Ansible

Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient waySylvain Rayé
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPDana Luther
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOpsОмские ИТ-субботники
 
One click deployment
One click deploymentOne click deployment
One click deploymentAlex Su
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stackDana Luther
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to AnsibleCédric Delgehier
 
Professional deployment
Professional deploymentProfessional deployment
Professional deploymentIvelina Dimova
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupalDay
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
02 Hadoop deployment and configuration
02 Hadoop deployment and configuration02 Hadoop deployment and configuration
02 Hadoop deployment and configurationSubhas Kumar Ghosh
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudSalesforce Developers
 
Oracle11g On Fedora14
Oracle11g On Fedora14Oracle11g On Fedora14
Oracle11g On Fedora14kmsa
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsVisual Engineering
 
Chef - industrialize and automate your infrastructure
Chef - industrialize and automate your infrastructureChef - industrialize and automate your infrastructure
Chef - industrialize and automate your infrastructureMichaël Lopez
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy Systemadrian_nye
 
OpenWRT guide and memo
OpenWRT guide and memoOpenWRT guide and memo
OpenWRT guide and memo家榮 吳
 
How to make debian package from scratch (linux)
How to make debian package from scratch (linux)How to make debian package from scratch (linux)
How to make debian package from scratch (linux)Thierry Gayet
 
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Aleksey Tkachenko
 

Similar to Zero Downtime Deployment with Ansible (20)

Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
One click deployment
One click deploymentOne click deployment
One click deployment
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stack
 
#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
 
Professional deployment
Professional deploymentProfessional deployment
Professional deployment
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
02 Hadoop deployment and configuration
02 Hadoop deployment and configuration02 Hadoop deployment and configuration
02 Hadoop deployment and configuration
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the Cloud
 
Oracle11g On Fedora14
Oracle11g On Fedora14Oracle11g On Fedora14
Oracle11g On Fedora14
 
Oracle11g on fedora14
Oracle11g on fedora14Oracle11g on fedora14
Oracle11g on fedora14
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build tools
 
Chef - industrialize and automate your infrastructure
Chef - industrialize and automate your infrastructureChef - industrialize and automate your infrastructure
Chef - industrialize and automate your infrastructure
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
OpenWRT guide and memo
OpenWRT guide and memoOpenWRT guide and memo
OpenWRT guide and memo
 
How to make debian package from scratch (linux)
How to make debian package from scratch (linux)How to make debian package from scratch (linux)
How to make debian package from scratch (linux)
 
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...
 

More from Stein Inge Morisbak

Orkestrering av IT-utvikling i Store Organisasjoner
Orkestrering av IT-utvikling i Store OrganisasjonerOrkestrering av IT-utvikling i Store Organisasjoner
Orkestrering av IT-utvikling i Store OrganisasjonerStein Inge Morisbak
 
Verdien av kontinuerlige leveranser
Verdien av kontinuerlige leveranserVerdien av kontinuerlige leveranser
Verdien av kontinuerlige leveranserStein Inge Morisbak
 
Du kan ikke levere kontinuerlig om du har nedetid
Du kan ikke levere kontinuerlig om du har nedetidDu kan ikke levere kontinuerlig om du har nedetid
Du kan ikke levere kontinuerlig om du har nedetidStein Inge Morisbak
 
Er du moden for å levere kontinuerlig?
Er du moden for å levere kontinuerlig?Er du moden for å levere kontinuerlig?
Er du moden for å levere kontinuerlig?Stein Inge Morisbak
 
Hvis du ikke leverer kontinuerlig, så er du ikke smidig!
Hvis du ikke leverer kontinuerlig, så er du ikke smidig!Hvis du ikke leverer kontinuerlig, så er du ikke smidig!
Hvis du ikke leverer kontinuerlig, så er du ikke smidig!Stein Inge Morisbak
 

More from Stein Inge Morisbak (10)

Orkestrering av IT-utvikling i Store Organisasjoner
Orkestrering av IT-utvikling i Store OrganisasjonerOrkestrering av IT-utvikling i Store Organisasjoner
Orkestrering av IT-utvikling i Store Organisasjoner
 
Slutt med IT-prosjekter!
Slutt med IT-prosjekter!Slutt med IT-prosjekter!
Slutt med IT-prosjekter!
 
Devops or die!
Devops or die!Devops or die!
Devops or die!
 
Devops eller dø!
Devops eller dø!Devops eller dø!
Devops eller dø!
 
Verdien av kontinuerlige leveranser
Verdien av kontinuerlige leveranserVerdien av kontinuerlige leveranser
Verdien av kontinuerlige leveranser
 
Du kan ikke levere kontinuerlig om du har nedetid
Du kan ikke levere kontinuerlig om du har nedetidDu kan ikke levere kontinuerlig om du har nedetid
Du kan ikke levere kontinuerlig om du har nedetid
 
Er du moden for å levere kontinuerlig?
Er du moden for å levere kontinuerlig?Er du moden for å levere kontinuerlig?
Er du moden for å levere kontinuerlig?
 
Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 
Hvis du ikke leverer kontinuerlig, så er du ikke smidig!
Hvis du ikke leverer kontinuerlig, så er du ikke smidig!Hvis du ikke leverer kontinuerlig, så er du ikke smidig!
Hvis du ikke leverer kontinuerlig, så er du ikke smidig!
 
Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 

Recently uploaded

Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 

Recently uploaded (20)

Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 

Zero Downtime Deployment with Ansible

  • 1. ZERO DOWNTIME DEPLOYMENT WITH ANSIBLE OPEN
  • 2. SLIDES & REPO http://steinim.github.io/slides/zero-downtime-ansible https://github.com/steinim/zero-downtime-ansible
  • 3. WHAT'S A PROVISIONING FRAMEWORK? Automated setup of servers Configuration as code
  • 4. EXAMPLES Create users Install software Generate and manipulate config files Start/stop/restart processes Set up dependencies between operations
  • 5. DESCRIBE WHAT TO DO #!/bin/bash if $( command -v vim >/dev/null 2>&1 ); then echo "vim is already installed." else apt-get install vim fi if $( grep -Fxq "filetype indent off" /etc/vim/vimrc ); then echo "set filetype indent off is already in /etc/vim/vimrc." else echo "filetype indent off" >> /etc/vim/vimrc # TODO: Do not continue if this fails. fi # TODO: Rollback if something fails.
  • 6. DESCRIBE STATE - name: ensure installed vim apt: pkg=vim state=installed - name: set filetype indent off for vim lineinfile: dest=/etc/vim/vimrc line='filetype indent off' state=present
  • 7. ANSIBLE SSH-based Client only (no server) YAML configuration Push (and pull) Supports more than setup and provisioning: Application deployment Remote command execution
  • 8. BRING UP THE BOXES vagrant up
  • 9. LAYOUT ├── ansible.cfg ├── hosts ├── site.yml ├── group_vars │ └── <group name> ├── host_vars │ └── <host name> ├── roles │ ├── <role> │ │ ├── files │ │ └── <file> │ │ └── templates │ │ └── <template>.j2 │ │ ├── handlers │ │ │ └── main.yml │ │ ├── tasks │ │ │ └── main.yml
  • 11. FACTS Ansible by default gathers “facts” about the machines under management. These facts can be accessed in Playbooks and in templates. ansible -m setup app1.local
  • 12. THE TASK An app user 'devops', with: Home directory: /home/devops ssh-key A PostgresSQL database. Nginx as a reverse proxy. An init script installed as a service. Deploy an application that uses the provisioned infrastructure.
  • 13.
  • 15. TASK1: INSTALL AND CONFIGURE SOFTWARE git checkout start Modify roles/common/tasks/apt.yml. Install Vim. Insert the line 'filetype indent off' in /etc/vim/vimrc Help: http://docs.ansible.com/apt_module.html http://docs.ansible.com/lineinfile_module.html git checkout task1_help
  • 16. TASK1: SOLUTION git diff HEAD origin/task1 git checkout task1 # or keep your own solution ansible-playbook site.yml --tags apt,vim ProTip: Use '--tags', '--skip-tags', '--limit' and/or 'gather_facts: False' to reduce execution time.
  • 17. PROGRESS Installed software Manipulated files
  • 18. VARIABLES Ansible uses variables (a lot!). Inventory group_vars and host_vars Playbook Facts Command line Access variables from playbooks: "{{ variable }}" http://docs.ansible.com/playbooks_variables.html
  • 19. TASK2: CREATE AN APPLICATION USER Create roles/users/tasks/main.yml Home directory: /home/devops ssh-key Use variables! (group_vars) Help: http://docs.ansible.com/group_module.html http://docs.ansible.com/user_module.html http://docs.ansible.com/file_module.html (copy ssh-key) http://docs.ansible.com/lineinfile_module.html (.ssh/authorized_keys) http://docs.ansible.com/playbooks_best_practices.html#group-and-host-variables git checkout task2_help
  • 20. TASK2: SOLUTION git diff HEAD origin/task2 git checkout task2 # or keep your own solution ansible-playbook site.yml --limit appservers --skip-tags apt,vim,java ssh devops@app1.local
  • 21. PROGRESS Installed software Manipulated files Created a user and set up a ssh-key
  • 22. TASK3: INSTALL AND CONFIGURE POSTGRESQL roles/postgresql ├── files │ ├── ACCC4CF8.asc │ └── postgresql.conf ├── handlers │ └── main.yml ├── tasks │ ├── main.yml │ └── ... └── templates └── pg_hba.conf.j2 Use variables (group_vars/all and/or group_vars/dbservers). Use handler to restart postgresql upon notification Template: git checkout master -- roles/postgresql/templates/pg_hba.conf.j2 Help: http://docs.ansible.com/template_module.html (pg_hba.conf.j2) http://docs.ansible.com/postgresql_user_module.html http://docs.ansible.com/postgresql_db_module.html http://docs.ansible.com/playbooks_intro.html#handlers-running-operations-on-change http://docs.ansible.com/playbooks_best_practices.html#group-and-host-variables
  • 23. TASK3: SOLUTION git diff HEAD origin/task3 git checkout task3 # or keep your own solution ansible-playbook site.yml --limit dbservers --tags pg_install $ vagrant ssh db vagrant@db:~$ psql -d devops -U devops -W devops=> q
  • 24. PROGRESS Installed software Manipulated files Created a user and set up a ssh-key Installed and configured a database and a db user
  • 25. TASK4: DEPLOY! roles/app ├── files │ └── init.sh ├── tasks │ └── main.yml └── templates └── config.properties.j2 NB! Use variables (./hosts). Set 'serial: 1' for appservers in site.yml. Help: http://docs.ansible.com/service_module.html
  • 26. TASK4: SOLUTION Browse to http://app1.local:1234/ git diff HEAD origin/task4 git checkout task4 # or keep your own solution ansible-playbook site.yml --limit appservers --tags deploy
  • 27. WHAT JUST HAPPENED? /home/devops ├── config.properties ├── current -> /home/devops/devops_1416228023.jar ├── previous -> /home/devops/devops_1416221573.jar ├── devops_1416221573.jar ├── devops_1416228023.jar └── logs ├── stderr.log └── stdout.log /etc/init.d └── devops
  • 28. PROGRESS Installed software Manipulated files Created a user and set up a ssh-key Installed and configured a database and a db user Deployed an application to two appservers and enabled it as a service
  • 29. TASK5: DEPLOY DATABASE roles/db ├── files │ └── migrate_db.sql └── tasks └── main.yml Help: http://docs.ansible.com/command_module.html psql -d {{ db.name }} -q -f /tmp/migrate_db.sql sudo_user: postgres
  • 30. TASK5: SOLUTION Browse to http://app1.local:1234/ git diff HEAD origin/task5 git checkout task5 # or keep your own solution ansible-playbook site.yml --limit dbservers --tags deploy $ vagrant ssh db vagrant@db:~$ psql -d devops -U devops -W devops=> dt devops=> select * from hello; devops=> q
  • 31. PROGRESS Installed software Manipulated files Created a user and set up a ssh-key Installed and configured a database and a db user Deployed an application to two appservers and enabled it as a service Migrated the database schema and fetched data from it through the application
  • 32. TASK6: SET UP PROXY roles/nginx ├── handlers │ └── main.yml ├── tasks │ ├── config_nginx.yml │ ├── install_nginx.yml │ └── main.yml └── templates └── devops.conf.j2 Help: http://wsgiarea.pocoo.org/jinja/docs/loops.html
  • 33. TASK6: SOLUTION Browse to # refresh http://proxy.local/ me many times git diff HEAD origin/task6 git checkout task6 # or keep your own solution ansible-playbook site.yml --limit proxies --tags nginx
  • 34. PROGRESS Installed software Manipulated files Created a user and set up a ssh-key Installed and configured a database and a db user Deployed an application to two appservers and enabled it as a service Migrated the database schema and fetched data from it through the application Set up a reverse proxy for automatic failover between the two appservers
  • 35. THE EXPAND/CONTRACT PATTERN Expand Contract Add tables Add columns Tweak indexes Remove tables Remove columns Remove/add constraints
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42. PLAY TIME :-) Suggestions: Change database table name from HELLO to MESSAGES and deploy a new version without downtime. Implement automated rollback.
  • 43. I HAVE BEEN PLAYING :-) git checkout play ansible-playbook site.yml --limit appservers,dbservers --tags deploy ansible-playbook site.yml --limit appservers,dbservers --tags rollback
  • 44. THANK YOU! @steinim stein.inge.morisbak@BEKK.no