Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Upcoming SlideShare
Loading in...5

Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)



This is the presentation given at the Symfony Live 2011 conference. It is an introduction to the new agile movement spreading in the technical operations community called DevOps and how to adopt it on ...

This is the presentation given at the Symfony Live 2011 conference. It is an introduction to the new agile movement spreading in the technical operations community called DevOps and how to adopt it on web development projects, in particular Symfony projects.

Plan of the slides :
- Configuration Management
- Development VM
- Scripted deployment
- Continuous deployment

Tools presented in the slides:
- Puppet
- Vagrant
- Fabric
- Jenkins / Hudson



Total Views
Views on SlideShare
Embed Views



19 Embeds 3,174 2368 324 171 138 62 41 15 12 7 6 6 5 5 5 3 3 1 1 1



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011) Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011) Presentation Transcript

  • Adopt Devops philosophy on your Symfony projects An introduction to Devops by Fabrice Bernhard
  • MeFabrice Bernhard
  • Co-founder / CTO of Theodo and
  • Theodo creates web-based applicationswith open-source web technologies, agile methodologies and the higheststandards of qualityto guarantee rapid application development, risk-free deployment and easymaintenance for every client.
  • @skoop: Now, lets look for a bar in Paris where I could watch the FC Utrecht match:)
  • is the website for watching sports in bars in France and Spain( is used by 500 barmen (clients) and visited by more than 200,000unique visitors per monthPeaks on the biggest days can go up to 20,000 people in the 2 hours precedingthe is hosted on a cluster of 6 servers
  • What is DevOps? Introduction
  • How many here consider themselves SysAdmins?
  • How many here have never deployed an application on a server?
  • WikipediaDefinition of DevOpsDevOps is a set of processes, methods and systems for communication,collaboration and integration between departments for Development(Applications/Software Engineering), Technology Operations and Quality Assurance(QA).It relates to the emerging understanding of the interdependence of developmentand operations in meeting a business goal to producing timely software productsand services
  • The fundamental DevOps contradictionDevs VS Ops Developers are asked to deliver new value, often and fast Operations people are asked to protect the current value Pro-Change VS Pro-Stability
  • Silos
  • Break the silos
  • DevOps do RADD
  • DevOps create the infrastructure that empower devs from the first line of code to the deliveryHow to be DevOps? Configuration management for rapid, repeatable server setup Deployment scripts to abstract sysadmin tasks and empower developers Development VMs with prod configuration to ensure consistency and avoid unexpected system-related bugs Continuous deployment to make it fast!
  • DevOps is spreading agility to the whole IT project lifecycle
  • Rapid and repeatable server setup Configuration management with Puppet
  • What is configuration management?Writing the system configuration of your servers in filesApplying these files automaticallyThats it!
  • Why do configuration management?To do fast cluster deployment: who wants to manually setup 50 EC2 servers???To do fast crash-recovery: configuration management is the best documentationfor a servers setupTo have consistent environments for development and production
  • Puppet or ChefConfiguration management tools Two popular recent tools for configuration management: Puppet and Chef A master server contains different "recipes" describing system configurations Client servers connect to the master server, read their recipe, and apply the configuration
  • Puppet
  • Puppet references
  • Let us create a Symfony-ready server with Puppet Introduction to Puppet manifests
  • class lighttpd{ package { "apache2.2-bin": ensure => absent, } package { "lighttpd": ensure => present, } service { "lighttpd": ensure => running, require => Package["lighttpd", "apache2.2-bin"], }}
  • class lighttpd-phpmysql-fastcgi inherits lighttpd{ package { "php5-cgi": ensure => present, } package { "mysql-server": ensure => present, } exec { "lighttpd-enable-mod fastcgi": path => "/usr/bin:/usr/sbin:/bin", creates => "/etc/lighttpd/conf-enabled/10-fastcgi.conf", require => Package["php5-cgi", "lighttpd"], }}
  • class symfony-server inherits lighttpd-phpmysql-fastcgi{ package { ["php5-cli", "php5-sqlite"]: ensure => present, notify => Service["lighttpd"], } package { "git-core": ensure => present, } exec { "git clone git://": path => "/usr/bin:/usr/sbin:/bin", cwd => "/var/www", creates => "/var/www/symfony1", require => Package["lighttpd", "git-core"], }}
  • class symfony-live-server inherits symfony-server{ file { "/etc/lighttpd/conf-available/99-hosts.conf": source => "/vagrant/files/conf/hosts.conf", notify => Service["lighttpd"], } exec { "lighttpd-enable-mod hosts": path => "/usr/bin:/usr/sbin:/bin", creates => "/etc/lighttpd/conf-enabled/99-hosts.conf", require => File["/etc/lighttpd/conf-available/99-hosts.conf"], notify => Service["lighttpd"], }}include symfony-live-servernotice("Symfony server is going live!")
  • Why not use shell scripts?Shell scripts are for administrators. Is all your team composed of admin experts?Even for admin experts, Puppet and Chef recipes are more readablePuppet and Chef make inheritance and modules easyPuppet and Chef are idempotent: running them twice in a row will not breakyour system
  • Develop and test on the sameenvironment as in production! VM provisioning with Vagrant
  • Develop on local Virtual MachinesVagrant Vagrant is a tool to create local VirtualBox VMs, configured automatically by your Chef recipe or Puppet manifest It ensures you test on the same environment as your production server It is VERY easy
  • All you need is:Vagrant A Puppet manifest A few system config files A Vagrant conf file
  • DemonstrationVagrant $ git clone git:// . $ git clone git:// $ vagrant up
  • Give developers the power to deploy themselves Scripted deployment
  • DeploymentDeployment is a very critical task usually done by adminsRemember Murphys law: "If anything can go wrong, it will"W hen things go wrong, most of the time developers have the solutionSo give the developers the responsibility to deploy, rollback, correct and deployagain!
  • Scripting deployment can be VERY easySimple Fabric script example # from fabric.api import * env.hosts = [] def deploy(): with cd(/theodo/sflive2011): run(git pull) run(./symfony doc:build --all --no-confirmation) run(./symfony cc) $ fab deploy
  • A good practise: scripting a rollbackAnother Fabric example # def deploy(): tag = "prod/%s" % strftime("%Y/%m-%d-%H-%M-%S") local(git tag -a %s -m "Prod" % tag) local(git push --tags) with cd(path): run(git fetch) tag = run(git tag -l prod/* | sort | tail -n1) run(git checkout + tag) def rollback(num_revs=1): with cd(path): run(git fetch) tag = run(git tag -l prod/* | sort | tail -n + str(1 + int(num_revs)) + | head -n1) run(git checkout + tag)
  • And why not let Jenkins deploy himself? Continuous deployment
  • The Holy Grail of Rapid App Development & Deployment: Automate everything low value-added and relax
  • Isnt it dangerous to trust a machine?Errare humanum est Of course you need continuous integration with MANY tests Of course you need some serious monitoring on the production server Of course you need some good rollback scripts But arent that good things to do anyway ? Good continuous integration is more reliable than a human!
  • You need to separate dev, pre-prod and prod...Continuous deployment howtoFor example with git: features/* branches for small projects dev branch for merging team development master branch for production-ready code prod/* tags for production
  • And you need a deployment script + JenkinsContinuous deployment howto Deployment script using Fabric (for example) Jenkins (formerly known as Hudson) to test and deploy
  • Create a new Jenkins project testing only branch master
  • Specify "Build other projects" in the post-build actions
  • Dont forget to activate Chuck Norris
  • Create a second Jenkins project to execute the deploy script
  • Thats it!
  • Next step
  • DevOps many more devops meetups around the world
  • Many thanks to Samuel @smaftoul Maftoul, organiser of the Paris DevOps meetup, who bootstrapped me on DevOps!
  • Questions?