SlideShare a Scribd company logo
ANSIBLE-PROJECT-DEPLOY
a re-usable Ansible role to deploy projects
ABOUT US
2
Ramon de la Fuente	

@f_u_e_n_t_e
Jasper N. Brouwer	

@jaspernbrouwer
Future500 B.V.
THE PROBLEM
3
THE PROBLEM
• Continuous deployment	

• Easy maintenance of the deploy procedure.	

• Small learning curve.	

• Reuse between projects with little effort.
4
WHAT IS A DEPLOY?
5
WHAT IS A DEPLOY?
Directory structure:
.
!"" releases
| !"" 20140415234508
| #"" 20140415235146
!"" shared
| !"" sessions
| !"" source
| #"" uploads
#"" current -> releases/20140415235146
6
WHAT IS A DEPLOY?
Directory structure:
.
!"" releases
| !"" 20140415234508
| #"" 20140415235146
!"" shared
| !"" sessions
| !"" source
| #"" uploads
#"" current -> releases/20140415235146
7
WHAT IS A DEPLOY?
1. Update the codebase + configuration
8
WHAT IS A DEPLOY?
1. Update the codebase + configuration	

2. Install dependencies
9
WHAT IS A DEPLOY?
1. Update the codebase + configuration	

2. Install dependencies	

3. Preserve shared resources
10
WHAT IS A DEPLOY?
1. Update the codebase + configuration	

2. Install dependencies	

3. Preserve shared resources	

4. Build tasks
11
WHAT IS A DEPLOY?
1. Update the codebase + configuration	

2. Install dependencies	

3. Preserve shared resources	

4. Build tasks	

5. Finalize
12
THE ROLE
13
https://galaxy.ansible.com/list#/roles/732
project_deploy
ROLE WALKTHROUGH
14
ROLE WALKTHROUGH
!
Deploy module variables:
!
deploy:
project_path
current_path
releases_path
shared_path
last_release
last_release_path
new_release
new_release_path
unfinished_filename
!
!
15
ROLE WALKTHROUGH
!
Deploy module variables:
!
deploy:
project_path: /path/to/project/
current_path: /path/to/project/current
releases_path: /path/to/project/releases
shared_path: /path/to/project/shared
last_release: 20140415234508
last_release_path: /path/to/project/releases/20140415234508
new_release: 20140415235146
new_release_path: /path/to/project/releases/20140415235146
unfinished_filename: DEPLOY_UNFINISHED
Used as:
{{ deploy.new_release }}
16
1. UPDATETHE CODEBASE
!
- name: Clone project files
git: repo={{ project_git_repo }}
dest={{ project_source_path }}
version={{ project_version }}
when: project_deploy_strategy == 'git'
!
- name: Rsync project files
synchronize: src={{ project_local_path }}
dest={{ project_source_path }}
rsync_timeout={{ project_deploy_synchronize_timeout }}
recursive=yes
when: project_deploy_strategy == 'synchronize'
!
17
1. UPDATETHE CODEBASE
!
- name: Clone project files
git: repo={{ project_git_repo }}
dest={{ project_source_path }}
version={{ project_version }}
when: project_deploy_strategy == 'git'
!
- name: Rsync project files
synchronize: src={{ project_local_path }}
dest={{ project_source_path }}
rsync_timeout={{ project_deploy_synchronize_timeout }}
recursive=yes
when: project_deploy_strategy == 'synchronize'
!
18
1. UPDATETHE CODEBASE
!
- name: Clone project files
git: repo={{ project_git_repo }}
dest={{ project_source_path }}
version={{ project_version }}
when: project_deploy_strategy == 'git'
!
- name: Rsync project files
synchronize: src={{ project_local_path }}
dest={{ project_source_path }}
rsync_timeout={{ project_deploy_synchronize_timeout }}
recursive=yes
when: project_deploy_strategy == 'synchronize'
!
19
1. UPDATETHE CODEBASE
!
- name: Write unfinished file
file: path={{ project_source_path }}/{{ deploy.unfinished_filename }}
state=touch
!
- name: Copy files to new build dir
command: "cp -pr {{ project_source_path }} {{ deploy.new_release_path }}"
!
- name: Remove unwanted files/folders from new release
file: path={{ deploy.new_release_path }}/{{ item }} state=absent
with_items: project_unwanted_items
20
1. UPDATETHE CONFIG FILES
!
- name: Copy project files
copy: src={{ item.src }}
dest={{ deploy.new_release_path }}/{{ item.dest }}
mode={{ item.mode|default('0644') }}
with_items: project_files
!
- name: Copy project templates
template: src={{ item.src }}
dest={{ deploy.new_release_path }}/{{ item.dest }}
mode={{ item.mode|default('0644') }}
with_items: project_templates
21
2. INSTALL DEPENDENCIES
!
- name: Do composer install
command: "{{ project_command_for_composer_install }} chdir=…"
environment: project_environment
when: project_has_composer
!
- name: Do npm install
command: "{{ project_command_for_npm_install }} chdir=…"
environment: project_environment
when: project_has_npm
!
- name: Do bower install
command: "{{ project_command_for_bower_install }} chdir=…"
environment: project_environment
when: project_has_bower
22
2. INSTALL DEPENDENCIES
!
- name: Do composer install
command: "{{ project_command_for_composer_install }} chdir=…"
environment: project_environment
when: project_has_composer
!
- name: Do npm install
command: "{{ project_command_for_npm_install }} chdir=…"
environment: project_environment
when: project_has_npm
!
- name: Do bower install
command: "{{ project_command_for_bower_install }} chdir=…"
environment: project_environment
when: project_has_bower
23
3. SHARED RESOURCES
!
- name: Ensure shared sources are present
file: "path='{{ deploy.shared_path }}/{{ item.src }}' state={{ item.type }}“
with_items: project_shared_children
!
- name: Ensure shared paths are absent
file: "path='{{ deploy.new_release_path }}/{{ item.path }}' state=absent"
with_items: project_shared_children
!
- name: Create shared symlinks
file: path='{{ deploy.new_release_path }}/{{ item.path }}'
src='{{ deploy.shared_path }}/{{ item.src }}'
state=link"
with_items: project_shared_children
24
4. BUILD STEPS
!
- name: Run post_build_commands in the new_release_path
command: "{{ item }} chdir={{ deploy.new_release_path }}"
with_items: project_post_build_commands
environment: project_environment
25
4. BUILD STEPS
!
- name: Run post_build_commands in the new_release_path
command: "{{ item }} chdir={{ deploy.new_release_path }}"
with_items: project_post_build_commands
environment: project_environment
26
!
project_post_build_commands:
- "app/console cache:clear"
- "app/console assets:install"
- "app/console assetic:dump"
5. FINALIZE
!
- name: Remove unfinished file
file: path={{ deploy.new_release_path }}/{{ deploy.unfinished_filename }}
state=absent
when: project_finalize
!
- name: Finalize the deploy
file: src={{ deploy.new_release_path }} dest={{ deploy.current_path }}
state=link
when: project_finalize
27
28
IT’S NOT COMPLICATED!
• Only 75 lines	

• Number of tasks: 18	

• Variables to configure: 24
29
EXAMPLE PLAYBOOK
30
EXAMPLE PLAYBOOK
!
- name: Deploy the application
hosts: production
remote_user: "{{ production_deploy_user }}"
sudo: no
!
vars:
project_root: "{{ sweetlakephp_root }}"
project_git_repo: "{{ sweetlakephp_github_repo }}"
project_deploy_strategy: git
31
EXAMPLE PLAYBOOK
!
- name: Deploy the application
hosts: production
remote_user: "{{ production_deploy_user }}"
sudo: no
!
vars:
project_root: "{{ sweetlakephp_root }}"
project_git_repo: "{{ sweetlakephp_github_repo }}"
project_deploy_strategy: git
!
project_environment:
SYMFONY_ENV: "prod"
32
EXAMPLE PLAYBOOK
!
project_environment:
SYMFONY_ENV: "prod"
!
project_shared_children:
- path: "/app/sessions"
src: "sessions"
- path: "/web/uploads"
src: "uploads"
!
project_templates:
- name: parameters.yml
src: "templates/parameters_prod.yml.j2"
dest: "/app/config/parameters_prod.yml"
!
33
EXAMPLE PLAYBOOK
!
project_environment:
SYMFONY_ENV: "prod"
!
project_shared_children:
- path: "/app/sessions"
src: "sessions"
- path: "/web/uploads"
src: "uploads"
!
project_templates:
- name: parameters.yml
src: "templates/parameters_prod.yml.j2"
dest: "/app/config/parameters_prod.yml"
!
34
EXAMPLE PLAYBOOK
!
project_has_composer: yes
!
project_post_build_commands:
- "php vendor/sensio/…/DistributionBundle/…/bin/build_bootstrap.php”
- "app/console cache:clear"
- "app/console doctrine:migrations:migrate --no-interaction"
- "app/console assets:install"
- "app/console assetic:dump"
!
roles:
- f500.project_deploy
!
post_tasks:
- name: Remove old releases
deploy: "path={{ project_root }} state=clean"
35
EXAMPLE PLAYBOOK
!
project_has_composer: yes
!
project_post_build_commands:
- "php vendor/sensio/…/DistributionBundle/…/bin/build_bootstrap.php”
- "app/console cache:clear"
- "app/console doctrine:migrations:migrate --no-interaction"
- "app/console assets:install"
- "app/console assetic:dump"
!
roles:
- f500.project_deploy
!
post_tasks:
- name: Remove old releases
deploy: "path={{ project_root }} state=clean"
36
THANKYOU!
37
Feedback: https://joind.in/11570
https://github.com/f500/ansible-project_deploy

More Related Content

What's hot

Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with Jenkins
Adam Culp
 
Building and deploying PHP applications with Phing
Building and deploying PHP applications with PhingBuilding and deploying PHP applications with Phing
Building and deploying PHP applications with Phing
Michiel Rook
 
Automated Deployment With Phing
Automated Deployment With PhingAutomated Deployment With Phing
Automated Deployment With Phing
Daniel Cousineau
 
Make an Instant Website with Webhooks
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with Webhooks
Anne Gentle
 
Building and Deploying PHP apps with Phing
Building and Deploying PHP apps with PhingBuilding and Deploying PHP apps with Phing
Building and Deploying PHP apps with Phing
Michiel Rook
 
Composer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.pptComposer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.ppt
Promet Source
 
Phing: Building with PHP
Phing: Building with PHPPhing: Building with PHP
Phing: Building with PHP
hozn
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
Michiel Rook
 
Introduction to Git / Github
Introduction to Git / GithubIntroduction to Git / Github
Introduction to Git / Github
Paige Bailey
 
Automatisation in development and testing - within budget [IronCamp prague 20...
Automatisation in development and testing - within budget [IronCamp prague 20...Automatisation in development and testing - within budget [IronCamp prague 20...
Automatisation in development and testing - within budget [IronCamp prague 20...
David Lukac
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
Becky Todd
 
Building a Drupal site with Git
Building a Drupal site with GitBuilding a Drupal site with Git
Building a Drupal site with Git
dirtytactics
 
11 tools for your PHP devops stack
11 tools for your PHP devops stack11 tools for your PHP devops stack
11 tools for your PHP devops stack
Kris Buytaert
 
Be a microservices hero
Be a microservices heroBe a microservices hero
Be a microservices hero
OpenRestyCon
 
hw1a
hw1ahw1a
How%20to%20install%20PHP%20on%20Linux%20_%20laffers
How%20to%20install%20PHP%20on%20Linux%20_%20laffersHow%20to%20install%20PHP%20on%20Linux%20_%20laffers
How%20to%20install%20PHP%20on%20Linux%20_%20laffers
tutorialsruby
 
Working with Git
Working with GitWorking with Git
Working with Git
Sanghoon Hong
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
Pablo Godel
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
Matt Gauger
 
Propel Your PHP Applications
Propel Your PHP ApplicationsPropel Your PHP Applications
Propel Your PHP Applications
hozn
 

What's hot (20)

Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with Jenkins
 
Building and deploying PHP applications with Phing
Building and deploying PHP applications with PhingBuilding and deploying PHP applications with Phing
Building and deploying PHP applications with Phing
 
Automated Deployment With Phing
Automated Deployment With PhingAutomated Deployment With Phing
Automated Deployment With Phing
 
Make an Instant Website with Webhooks
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with Webhooks
 
Building and Deploying PHP apps with Phing
Building and Deploying PHP apps with PhingBuilding and Deploying PHP apps with Phing
Building and Deploying PHP apps with Phing
 
Composer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.pptComposer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.ppt
 
Phing: Building with PHP
Phing: Building with PHPPhing: Building with PHP
Phing: Building with PHP
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
 
Introduction to Git / Github
Introduction to Git / GithubIntroduction to Git / Github
Introduction to Git / Github
 
Automatisation in development and testing - within budget [IronCamp prague 20...
Automatisation in development and testing - within budget [IronCamp prague 20...Automatisation in development and testing - within budget [IronCamp prague 20...
Automatisation in development and testing - within budget [IronCamp prague 20...
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Building a Drupal site with Git
Building a Drupal site with GitBuilding a Drupal site with Git
Building a Drupal site with Git
 
11 tools for your PHP devops stack
11 tools for your PHP devops stack11 tools for your PHP devops stack
11 tools for your PHP devops stack
 
Be a microservices hero
Be a microservices heroBe a microservices hero
Be a microservices hero
 
hw1a
hw1ahw1a
hw1a
 
How%20to%20install%20PHP%20on%20Linux%20_%20laffers
How%20to%20install%20PHP%20on%20Linux%20_%20laffersHow%20to%20install%20PHP%20on%20Linux%20_%20laffers
How%20to%20install%20PHP%20on%20Linux%20_%20laffers
 
Working with Git
Working with GitWorking with Git
Working with Git
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
 
Propel Your PHP Applications
Propel Your PHP ApplicationsPropel Your PHP Applications
Propel Your PHP Applications
 

Viewers also liked

Extracting wisdom from stupidity
Extracting wisdom from stupidityExtracting wisdom from stupidity
Extracting wisdom from stupidity
Ramon de la Fuente
 
COLECTAREA DATELOR ÎN SISTEME INFORMATICE ȘI UTILIZAREA LOR ÎN OPTIMIZAREA EX...
COLECTAREA DATELOR ÎN SISTEME INFORMATICE ȘI UTILIZAREA LOR ÎN OPTIMIZAREA EX...COLECTAREA DATELOR ÎN SISTEME INFORMATICE ȘI UTILIZAREA LOR ÎN OPTIMIZAREA EX...
COLECTAREA DATELOR ÎN SISTEME INFORMATICE ȘI UTILIZAREA LOR ÎN OPTIMIZAREA EX...
turdanews
 
Gouripur
GouripurGouripur
Gouripur
Hasan Bdboy
 
The challenges to clinical system adoption
The challenges to clinical system adoptionThe challenges to clinical system adoption
The challenges to clinical system adoption
rain2bow
 
Civics 101
Civics 101Civics 101
Civics 101
Andrew Phillips
 
Costos
CostosCostos
SweetlakePHP.1 year-aniversary
SweetlakePHP.1 year-aniversarySweetlakePHP.1 year-aniversary
SweetlakePHP.1 year-aniversary
Ramon de la Fuente
 
Capital structure
Capital structureCapital structure
Capital structure
Batti Husain
 
10 صفحه از سمفونی مردگان
10 صفحه از سمفونی مردگان10 صفحه از سمفونی مردگان
10 صفحه از سمفونی مردگان
qoqnoos
 
Andrew's solution
Andrew's solutionAndrew's solution
Andrew's solution
Andrew Phillips
 

Viewers also liked (13)

Extracting wisdom from stupidity
Extracting wisdom from stupidityExtracting wisdom from stupidity
Extracting wisdom from stupidity
 
COLECTAREA DATELOR ÎN SISTEME INFORMATICE ȘI UTILIZAREA LOR ÎN OPTIMIZAREA EX...
COLECTAREA DATELOR ÎN SISTEME INFORMATICE ȘI UTILIZAREA LOR ÎN OPTIMIZAREA EX...COLECTAREA DATELOR ÎN SISTEME INFORMATICE ȘI UTILIZAREA LOR ÎN OPTIMIZAREA EX...
COLECTAREA DATELOR ÎN SISTEME INFORMATICE ȘI UTILIZAREA LOR ÎN OPTIMIZAREA EX...
 
Gouripur
GouripurGouripur
Gouripur
 
howtoBlog
howtoBloghowtoBlog
howtoBlog
 
The challenges to clinical system adoption
The challenges to clinical system adoptionThe challenges to clinical system adoption
The challenges to clinical system adoption
 
Civics 101
Civics 101Civics 101
Civics 101
 
Costos
CostosCostos
Costos
 
Amar acche jol
Amar acche jolAmar acche jol
Amar acche jol
 
SweetlakePHP.1 year-aniversary
SweetlakePHP.1 year-aniversarySweetlakePHP.1 year-aniversary
SweetlakePHP.1 year-aniversary
 
Capital structure
Capital structureCapital structure
Capital structure
 
m5
m5m5
m5
 
10 صفحه از سمفونی مردگان
10 صفحه از سمفونی مردگان10 صفحه از سمفونی مردگان
10 صفحه از سمفونی مردگان
 
Andrew's solution
Andrew's solutionAndrew's solution
Andrew's solution
 

Similar to Ansible project-deploy (NomadPHP lightning talk)

Host any project in che with stacks & chefiles
Host any project in che with stacks & chefilesHost any project in che with stacks & chefiles
Host any project in che with stacks & chefiles
Florent BENOIT
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
Docker, Inc.
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
Rafe Colton
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
Vagmi Mudumbai
 
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
Future Processing
 
Docker for Ruby Developers
Docker for Ruby DevelopersDocker for Ruby Developers
Docker for Ruby Developers
Aptible
 
Building Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTMLBuilding Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTML
Olga Scrivner
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
Steffen Gebert
 
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins PipelinesAn Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
Steffen Gebert
 
AtlasCamp 2011: Confluence 4 and Beyond
AtlasCamp 2011: Confluence 4 and BeyondAtlasCamp 2011: Confluence 4 and Beyond
AtlasCamp 2011: Confluence 4 and Beyond
Sherif Mansour
 
DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020
Lohika_Odessa_TechTalks
 
Make BDD great again
Make BDD great againMake BDD great again
Make BDD great again
Yana Gusti
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
Fabio Fumarola
 
Continuous Integration and DevOps with Open Build Service(OBS)
Continuous Integration and DevOps with Open Build Service(OBS)Continuous Integration and DevOps with Open Build Service(OBS)
Continuous Integration and DevOps with Open Build Service(OBS)
Ralf Dannert
 
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented DesignCSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
Kate Travers
 
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QAFest
 
Presentation laravel 5 4
Presentation laravel 5 4Presentation laravel 5 4
Presentation laravel 5 4
Christen Gjølbye Christensen
 
Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chef
LeanDog
 
APEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfAPEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdf
Richard Martens
 
Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable Infrastructure
Adrian Otto
 

Similar to Ansible project-deploy (NomadPHP lightning talk) (20)

Host any project in che with stacks & chefiles
Host any project in che with stacks & chefilesHost any project in che with stacks & chefiles
Host any project in che with stacks & chefiles
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
[QE 2018] Adam Stasiak – Nadchodzi React Native – czyli o testowaniu mobilnyc...
 
Docker for Ruby Developers
Docker for Ruby DevelopersDocker for Ruby Developers
Docker for Ruby Developers
 
Building Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTMLBuilding Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTML
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins PipelinesAn Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
 
AtlasCamp 2011: Confluence 4 and Beyond
AtlasCamp 2011: Confluence 4 and BeyondAtlasCamp 2011: Confluence 4 and Beyond
AtlasCamp 2011: Confluence 4 and Beyond
 
DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020
 
Make BDD great again
Make BDD great againMake BDD great again
Make BDD great again
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Continuous Integration and DevOps with Open Build Service(OBS)
Continuous Integration and DevOps with Open Build Service(OBS)Continuous Integration and DevOps with Open Build Service(OBS)
Continuous Integration and DevOps with Open Build Service(OBS)
 
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented DesignCSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
 
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
QA Fest 2018. Adam Stasiak. React Native is Coming – the story of hybrid mobi...
 
Presentation laravel 5 4
Presentation laravel 5 4Presentation laravel 5 4
Presentation laravel 5 4
 
Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chef
 
APEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfAPEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdf
 
Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable Infrastructure
 

Recently uploaded

Do it again anti Republican shirt Do it again anti Republican shirt
Do it again anti Republican shirt Do it again anti Republican shirtDo it again anti Republican shirt Do it again anti Republican shirt
Do it again anti Republican shirt Do it again anti Republican shirt
exgf28
 
Week 1 - Pendidikan Pancasila - Gr 1.docx
Week 1 - Pendidikan Pancasila - Gr 1.docxWeek 1 - Pendidikan Pancasila - Gr 1.docx
Week 1 - Pendidikan Pancasila - Gr 1.docx
JunaManroe1
 
Mobile SEO India | Mobile SEO Service | Mobile SEO Company
Mobile SEO India | Mobile SEO Service | Mobile SEO CompanyMobile SEO India | Mobile SEO Service | Mobile SEO Company
Mobile SEO India | Mobile SEO Service | Mobile SEO Company
SIB Infotech
 
Saint Louis University diploma
Saint Louis University diplomaSaint Louis University diploma
Saint Louis University diploma
eufdev
 
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
QingjieDu1
 
My President is bulletproof t shirts hoodie
My President is bulletproof t shirts hoodieMy President is bulletproof t shirts hoodie
My President is bulletproof t shirts hoodie
exgf28
 
Trump fist pump t shirts Trump fist pump t shirts
Trump fist pump t shirts Trump fist pump t shirtsTrump fist pump t shirts Trump fist pump t shirts
Trump fist pump t shirts Trump fist pump t shirts
exgf28
 
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
yilin01100
 
Trump Assassination Shirt Trump Assassination Shirt
Trump Assassination Shirt Trump Assassination ShirtTrump Assassination Shirt Trump Assassination Shirt
Trump Assassination Shirt Trump Assassination Shirt
exgf28
 
upgrade to zabbix-7 0 como atualiza lts1
upgrade to zabbix-7 0 como atualiza lts1upgrade to zabbix-7 0 como atualiza lts1
upgrade to zabbix-7 0 como atualiza lts1
diogolsew
 
Geolocation and Geofeed Implementation bdNOG18
Geolocation and Geofeed Implementation bdNOG18Geolocation and Geofeed Implementation bdNOG18
Geolocation and Geofeed Implementation bdNOG18
Bangladesh Network Operators Group
 
New York Institute of Technology degree Cert diploma offer
New York Institute of Technology degree Cert diploma offerNew York Institute of Technology degree Cert diploma offer
New York Institute of Technology degree Cert diploma offer
ubovu
 
How God led me to DTS? Through many different signs and connections that I c...
How God led me to DTS? Through many different signs and connections that  I c...How God led me to DTS? Through many different signs and connections that  I c...
How God led me to DTS? Through many different signs and connections that I c...
AshishMohan57
 
Network Security version1.0 - Module 3.pptx
Network Security version1.0 - Module 3.pptxNetwork Security version1.0 - Module 3.pptx
Network Security version1.0 - Module 3.pptx
Infotainmentforall
 
Open Source TCP or Netflow Log Server Using Graylog
Open Source TCP or Netflow Log Server Using GraylogOpen Source TCP or Netflow Log Server Using Graylog
Open Source TCP or Netflow Log Server Using Graylog
Bangladesh Network Operators Group
 
Software Defined Networking, Concepts and Practical Implementations
Software Defined Networking, Concepts and Practical ImplementationsSoftware Defined Networking, Concepts and Practical Implementations
Software Defined Networking, Concepts and Practical Implementations
Bangladesh Network Operators Group
 
Enhancing seamless access using TIGERfed
Enhancing seamless access using TIGERfedEnhancing seamless access using TIGERfed
Enhancing seamless access using TIGERfed
Bangladesh Network Operators Group
 
Understanding Threat Intelligence | What is Threat Intelligence
Understanding Threat Intelligence | What is Threat IntelligenceUnderstanding Threat Intelligence | What is Threat Intelligence
Understanding Threat Intelligence | What is Threat Intelligence
Lumiverse Solutions Pvt Ltd
 
Maximizing Network Efficiency with Large Language Models (LLM)
Maximizing Network Efficiency with Large Language Models (LLM)Maximizing Network Efficiency with Large Language Models (LLM)
Maximizing Network Efficiency with Large Language Models (LLM)
Bangladesh Network Operators Group
 
Study of international anticancer research trends.pdf
Study of international anticancer research trends.pdfStudy of international anticancer research trends.pdf
Study of international anticancer research trends.pdf
Preston University
 

Recently uploaded (20)

Do it again anti Republican shirt Do it again anti Republican shirt
Do it again anti Republican shirt Do it again anti Republican shirtDo it again anti Republican shirt Do it again anti Republican shirt
Do it again anti Republican shirt Do it again anti Republican shirt
 
Week 1 - Pendidikan Pancasila - Gr 1.docx
Week 1 - Pendidikan Pancasila - Gr 1.docxWeek 1 - Pendidikan Pancasila - Gr 1.docx
Week 1 - Pendidikan Pancasila - Gr 1.docx
 
Mobile SEO India | Mobile SEO Service | Mobile SEO Company
Mobile SEO India | Mobile SEO Service | Mobile SEO CompanyMobile SEO India | Mobile SEO Service | Mobile SEO Company
Mobile SEO India | Mobile SEO Service | Mobile SEO Company
 
Saint Louis University diploma
Saint Louis University diplomaSaint Louis University diploma
Saint Louis University diploma
 
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
 
My President is bulletproof t shirts hoodie
My President is bulletproof t shirts hoodieMy President is bulletproof t shirts hoodie
My President is bulletproof t shirts hoodie
 
Trump fist pump t shirts Trump fist pump t shirts
Trump fist pump t shirts Trump fist pump t shirtsTrump fist pump t shirts Trump fist pump t shirts
Trump fist pump t shirts Trump fist pump t shirts
 
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
 
Trump Assassination Shirt Trump Assassination Shirt
Trump Assassination Shirt Trump Assassination ShirtTrump Assassination Shirt Trump Assassination Shirt
Trump Assassination Shirt Trump Assassination Shirt
 
upgrade to zabbix-7 0 como atualiza lts1
upgrade to zabbix-7 0 como atualiza lts1upgrade to zabbix-7 0 como atualiza lts1
upgrade to zabbix-7 0 como atualiza lts1
 
Geolocation and Geofeed Implementation bdNOG18
Geolocation and Geofeed Implementation bdNOG18Geolocation and Geofeed Implementation bdNOG18
Geolocation and Geofeed Implementation bdNOG18
 
New York Institute of Technology degree Cert diploma offer
New York Institute of Technology degree Cert diploma offerNew York Institute of Technology degree Cert diploma offer
New York Institute of Technology degree Cert diploma offer
 
How God led me to DTS? Through many different signs and connections that I c...
How God led me to DTS? Through many different signs and connections that  I c...How God led me to DTS? Through many different signs and connections that  I c...
How God led me to DTS? Through many different signs and connections that I c...
 
Network Security version1.0 - Module 3.pptx
Network Security version1.0 - Module 3.pptxNetwork Security version1.0 - Module 3.pptx
Network Security version1.0 - Module 3.pptx
 
Open Source TCP or Netflow Log Server Using Graylog
Open Source TCP or Netflow Log Server Using GraylogOpen Source TCP or Netflow Log Server Using Graylog
Open Source TCP or Netflow Log Server Using Graylog
 
Software Defined Networking, Concepts and Practical Implementations
Software Defined Networking, Concepts and Practical ImplementationsSoftware Defined Networking, Concepts and Practical Implementations
Software Defined Networking, Concepts and Practical Implementations
 
Enhancing seamless access using TIGERfed
Enhancing seamless access using TIGERfedEnhancing seamless access using TIGERfed
Enhancing seamless access using TIGERfed
 
Understanding Threat Intelligence | What is Threat Intelligence
Understanding Threat Intelligence | What is Threat IntelligenceUnderstanding Threat Intelligence | What is Threat Intelligence
Understanding Threat Intelligence | What is Threat Intelligence
 
Maximizing Network Efficiency with Large Language Models (LLM)
Maximizing Network Efficiency with Large Language Models (LLM)Maximizing Network Efficiency with Large Language Models (LLM)
Maximizing Network Efficiency with Large Language Models (LLM)
 
Study of international anticancer research trends.pdf
Study of international anticancer research trends.pdfStudy of international anticancer research trends.pdf
Study of international anticancer research trends.pdf
 

Ansible project-deploy (NomadPHP lightning talk)

  • 2. ABOUT US 2 Ramon de la Fuente @f_u_e_n_t_e Jasper N. Brouwer @jaspernbrouwer Future500 B.V.
  • 4. THE PROBLEM • Continuous deployment • Easy maintenance of the deploy procedure. • Small learning curve. • Reuse between projects with little effort. 4
  • 5. WHAT IS A DEPLOY? 5
  • 6. WHAT IS A DEPLOY? Directory structure: . !"" releases | !"" 20140415234508 | #"" 20140415235146 !"" shared | !"" sessions | !"" source | #"" uploads #"" current -> releases/20140415235146 6
  • 7. WHAT IS A DEPLOY? Directory structure: . !"" releases | !"" 20140415234508 | #"" 20140415235146 !"" shared | !"" sessions | !"" source | #"" uploads #"" current -> releases/20140415235146 7
  • 8. WHAT IS A DEPLOY? 1. Update the codebase + configuration 8
  • 9. WHAT IS A DEPLOY? 1. Update the codebase + configuration 2. Install dependencies 9
  • 10. WHAT IS A DEPLOY? 1. Update the codebase + configuration 2. Install dependencies 3. Preserve shared resources 10
  • 11. WHAT IS A DEPLOY? 1. Update the codebase + configuration 2. Install dependencies 3. Preserve shared resources 4. Build tasks 11
  • 12. WHAT IS A DEPLOY? 1. Update the codebase + configuration 2. Install dependencies 3. Preserve shared resources 4. Build tasks 5. Finalize 12
  • 15. ROLE WALKTHROUGH ! Deploy module variables: ! deploy: project_path current_path releases_path shared_path last_release last_release_path new_release new_release_path unfinished_filename ! ! 15
  • 16. ROLE WALKTHROUGH ! Deploy module variables: ! deploy: project_path: /path/to/project/ current_path: /path/to/project/current releases_path: /path/to/project/releases shared_path: /path/to/project/shared last_release: 20140415234508 last_release_path: /path/to/project/releases/20140415234508 new_release: 20140415235146 new_release_path: /path/to/project/releases/20140415235146 unfinished_filename: DEPLOY_UNFINISHED Used as: {{ deploy.new_release }} 16
  • 17. 1. UPDATETHE CODEBASE ! - name: Clone project files git: repo={{ project_git_repo }} dest={{ project_source_path }} version={{ project_version }} when: project_deploy_strategy == 'git' ! - name: Rsync project files synchronize: src={{ project_local_path }} dest={{ project_source_path }} rsync_timeout={{ project_deploy_synchronize_timeout }} recursive=yes when: project_deploy_strategy == 'synchronize' ! 17
  • 18. 1. UPDATETHE CODEBASE ! - name: Clone project files git: repo={{ project_git_repo }} dest={{ project_source_path }} version={{ project_version }} when: project_deploy_strategy == 'git' ! - name: Rsync project files synchronize: src={{ project_local_path }} dest={{ project_source_path }} rsync_timeout={{ project_deploy_synchronize_timeout }} recursive=yes when: project_deploy_strategy == 'synchronize' ! 18
  • 19. 1. UPDATETHE CODEBASE ! - name: Clone project files git: repo={{ project_git_repo }} dest={{ project_source_path }} version={{ project_version }} when: project_deploy_strategy == 'git' ! - name: Rsync project files synchronize: src={{ project_local_path }} dest={{ project_source_path }} rsync_timeout={{ project_deploy_synchronize_timeout }} recursive=yes when: project_deploy_strategy == 'synchronize' ! 19
  • 20. 1. UPDATETHE CODEBASE ! - name: Write unfinished file file: path={{ project_source_path }}/{{ deploy.unfinished_filename }} state=touch ! - name: Copy files to new build dir command: "cp -pr {{ project_source_path }} {{ deploy.new_release_path }}" ! - name: Remove unwanted files/folders from new release file: path={{ deploy.new_release_path }}/{{ item }} state=absent with_items: project_unwanted_items 20
  • 21. 1. UPDATETHE CONFIG FILES ! - name: Copy project files copy: src={{ item.src }} dest={{ deploy.new_release_path }}/{{ item.dest }} mode={{ item.mode|default('0644') }} with_items: project_files ! - name: Copy project templates template: src={{ item.src }} dest={{ deploy.new_release_path }}/{{ item.dest }} mode={{ item.mode|default('0644') }} with_items: project_templates 21
  • 22. 2. INSTALL DEPENDENCIES ! - name: Do composer install command: "{{ project_command_for_composer_install }} chdir=…" environment: project_environment when: project_has_composer ! - name: Do npm install command: "{{ project_command_for_npm_install }} chdir=…" environment: project_environment when: project_has_npm ! - name: Do bower install command: "{{ project_command_for_bower_install }} chdir=…" environment: project_environment when: project_has_bower 22
  • 23. 2. INSTALL DEPENDENCIES ! - name: Do composer install command: "{{ project_command_for_composer_install }} chdir=…" environment: project_environment when: project_has_composer ! - name: Do npm install command: "{{ project_command_for_npm_install }} chdir=…" environment: project_environment when: project_has_npm ! - name: Do bower install command: "{{ project_command_for_bower_install }} chdir=…" environment: project_environment when: project_has_bower 23
  • 24. 3. SHARED RESOURCES ! - name: Ensure shared sources are present file: "path='{{ deploy.shared_path }}/{{ item.src }}' state={{ item.type }}“ with_items: project_shared_children ! - name: Ensure shared paths are absent file: "path='{{ deploy.new_release_path }}/{{ item.path }}' state=absent" with_items: project_shared_children ! - name: Create shared symlinks file: path='{{ deploy.new_release_path }}/{{ item.path }}' src='{{ deploy.shared_path }}/{{ item.src }}' state=link" with_items: project_shared_children 24
  • 25. 4. BUILD STEPS ! - name: Run post_build_commands in the new_release_path command: "{{ item }} chdir={{ deploy.new_release_path }}" with_items: project_post_build_commands environment: project_environment 25
  • 26. 4. BUILD STEPS ! - name: Run post_build_commands in the new_release_path command: "{{ item }} chdir={{ deploy.new_release_path }}" with_items: project_post_build_commands environment: project_environment 26 ! project_post_build_commands: - "app/console cache:clear" - "app/console assets:install" - "app/console assetic:dump"
  • 27. 5. FINALIZE ! - name: Remove unfinished file file: path={{ deploy.new_release_path }}/{{ deploy.unfinished_filename }} state=absent when: project_finalize ! - name: Finalize the deploy file: src={{ deploy.new_release_path }} dest={{ deploy.current_path }} state=link when: project_finalize 27
  • 28. 28
  • 29. IT’S NOT COMPLICATED! • Only 75 lines • Number of tasks: 18 • Variables to configure: 24 29
  • 31. EXAMPLE PLAYBOOK ! - name: Deploy the application hosts: production remote_user: "{{ production_deploy_user }}" sudo: no ! vars: project_root: "{{ sweetlakephp_root }}" project_git_repo: "{{ sweetlakephp_github_repo }}" project_deploy_strategy: git 31
  • 32. EXAMPLE PLAYBOOK ! - name: Deploy the application hosts: production remote_user: "{{ production_deploy_user }}" sudo: no ! vars: project_root: "{{ sweetlakephp_root }}" project_git_repo: "{{ sweetlakephp_github_repo }}" project_deploy_strategy: git ! project_environment: SYMFONY_ENV: "prod" 32
  • 33. EXAMPLE PLAYBOOK ! project_environment: SYMFONY_ENV: "prod" ! project_shared_children: - path: "/app/sessions" src: "sessions" - path: "/web/uploads" src: "uploads" ! project_templates: - name: parameters.yml src: "templates/parameters_prod.yml.j2" dest: "/app/config/parameters_prod.yml" ! 33
  • 34. EXAMPLE PLAYBOOK ! project_environment: SYMFONY_ENV: "prod" ! project_shared_children: - path: "/app/sessions" src: "sessions" - path: "/web/uploads" src: "uploads" ! project_templates: - name: parameters.yml src: "templates/parameters_prod.yml.j2" dest: "/app/config/parameters_prod.yml" ! 34
  • 35. EXAMPLE PLAYBOOK ! project_has_composer: yes ! project_post_build_commands: - "php vendor/sensio/…/DistributionBundle/…/bin/build_bootstrap.php” - "app/console cache:clear" - "app/console doctrine:migrations:migrate --no-interaction" - "app/console assets:install" - "app/console assetic:dump" ! roles: - f500.project_deploy ! post_tasks: - name: Remove old releases deploy: "path={{ project_root }} state=clean" 35
  • 36. EXAMPLE PLAYBOOK ! project_has_composer: yes ! project_post_build_commands: - "php vendor/sensio/…/DistributionBundle/…/bin/build_bootstrap.php” - "app/console cache:clear" - "app/console doctrine:migrations:migrate --no-interaction" - "app/console assets:install" - "app/console assetic:dump" ! roles: - f500.project_deploy ! post_tasks: - name: Remove old releases deploy: "path={{ project_root }} state=clean" 36