![Page 1: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/1.jpg)
Adopt Devops philosophy on yourSymfony projects
An introduction to Devops
by Fabrice Bernhard
![Page 2: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/2.jpg)
MeFabrice Bernhard
![Page 4: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/4.jpg)
Co-founder / CTO of Theodo and Allomatch.com
![Page 5: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/5.jpg)
Theodo creates web-based applications
with open-source web technologies, agile methodologies and the higheststandards of quality
to guarantee rapid application development, risk-free deployment and easymaintenance for every client.
![Page 6: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/6.jpg)
@skoop: Now, let's look for a bar in Paris where I could watch the FC Utrecht match:)
![Page 7: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/7.jpg)
Allomatch.com is the website for watching sports in bars in France and Spain(sportandbar.es)
Allomatch is used by 500 barmen (clients) and visited by more than 200,000unique visitors per month
Peaks on the biggest days can go up to 20,000 people in the 2 hours precedingthe game
Allomatch.com is hosted on a cluster of 6 servers
![Page 8: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/8.jpg)
What is DevOps?Introduction
![Page 9: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/9.jpg)
How many here consider themselves SysAdmins?
![Page 10: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/10.jpg)
How many here have never deployed an application on aserver?
![Page 11: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/11.jpg)
WikipediaDefinition of DevOps
DevOps 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
![Page 12: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/12.jpg)
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
![Page 13: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/13.jpg)
Silos
![Page 14: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/14.jpg)
Break the silos
![Page 15: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/15.jpg)
DevOps do RADD
![Page 16: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/16.jpg)
DevOps create the infrastructure that empower devs fromthe first line of code to the delivery
How 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 avoidunexpected system-related bugs
Continuous deployment to make it fast!
![Page 17: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/17.jpg)
DevOps is spreading agility to the whole IT project lifecycle
![Page 18: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/18.jpg)
Rapid and repeatable server setupConfiguration management with Puppet
![Page 19: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/19.jpg)
What is configuration management?
Writing the system configuration of your servers in files
Applying these files automatically
That's it!
![Page 20: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/20.jpg)
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 server's setup
To have consistent environments for development and production
![Page 21: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/21.jpg)
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 theconfiguration
![Page 22: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/22.jpg)
Puppet
![Page 23: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/23.jpg)
Puppet references
![Page 24: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/24.jpg)
Let us create a Symfony-ready server with Puppet
Introduction to Puppet manifests
![Page 25: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/25.jpg)
class lighttpd{ package { "apache2.2-bin": ensure => absent, } package { "lighttpd": ensure => present, } service { "lighttpd": ensure => running, require => Package["lighttpd", "apache2.2-bin"], } }
![Page 26: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/26.jpg)
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"], }}
![Page 27: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/27.jpg)
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://github.com/symfony/symfony1.git": path => "/usr/bin:/usr/sbin:/bin", cwd => "/var/www", creates => "/var/www/symfony1", require => Package["lighttpd", "git-core"], }}
![Page 28: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/28.jpg)
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!")
![Page 29: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/29.jpg)
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 readable
Puppet and Chef make inheritance and modules easy
Puppet and Chef are idempotent: running them twice in a row will not breakyour system
![Page 30: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/30.jpg)
Develop and test on the sameenvironment as in production!
VM provisioning with Vagrant
![Page 31: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/31.jpg)
Develop on local Virtual MachinesVagrant
Vagrant is a tool to create local VirtualBox VMs, configured automatically by yourChef recipe or Puppet manifest
It ensures you test on the same environment as your production server
It is VERY easy
![Page 32: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/32.jpg)
All you need is:Vagrant
A Puppet manifest
A few system config files
A Vagrant conf file
![Page 33: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/33.jpg)
DemonstrationVagrant
$ git clone git://github.com/fabriceb/sflive2011vm.git .$ git clone git://github.com/fabriceb/sflive2011.git$ vagrant up
http://127.0.0.1:2011/
![Page 34: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/34.jpg)
Give developers the power to deploythemselves
Scripted deployment
![Page 35: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/35.jpg)
Deployment
Deployment is a very critical task usually done by admins
Remember Murphy's law: "If anything can go wrong, it will"
When things go wrong, most of the time developers have the solution
So give the developers the responsibility to deploy, rollback, correct and deployagain!
![Page 36: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/36.jpg)
Scripting deployment can be VERY easySimple Fabric script example
# fabfile.pyfrom fabric.api import *env.hosts = ['[email protected]']def deploy(): with cd('/theodo/sflive2011'): run('git pull') run('./symfony doc:build --all --no-confirmation') run('./symfony cc')
$ fab deploy
![Page 37: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/37.jpg)
A good practise: scripting a rollbackAnother Fabric example
# fabfile.pydef 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)
![Page 38: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/38.jpg)
And why not let Jenkins deployhimself?
Continuous deployment
![Page 39: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/39.jpg)
The Holy Grail of Rapid App Development & Deployment:
Automate everything low value-added
and relax
![Page 40: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/40.jpg)
Isn't 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 aren't that good things to do anyway ?
Good continuous integration is more reliable than a human!
![Page 41: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/41.jpg)
You need to separate dev, pre-prod and prod...Continuous deployment howto
For example with git:
features/* branches for small projects
dev branch for merging team development
master branch for production-ready code
prod/* tags for production
![Page 42: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/42.jpg)
And you need a deployment script + JenkinsContinuous deployment howto
Deployment script using Fabric (for example)
Jenkins (formerly known as Hudson) to test and deploy
![Page 43: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/43.jpg)
Create a new Jenkins project testing only branch master
![Page 44: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/44.jpg)
Specify "Build other projects" in the post-build actions
![Page 45: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/45.jpg)
Don't forget to activate Chuck Norris
![Page 46: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/46.jpg)
Create a second Jenkins project to execute the deploy script
![Page 47: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/47.jpg)
That's it!
![Page 48: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/48.jpg)
Next step
![Page 49: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/49.jpg)
Links
docs.puppetlabs.com
fabfile.org
vagrantup.com
github.com/fabriceb/sflive2011vm
![Page 50: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/50.jpg)
DevOps meetups
groups.google.com/group/paris-devops
and many more devops meetups around the world
![Page 51: Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)](https://reader034.vdocuments.net/reader034/viewer/2022052619/5562c57ad8b42a09618b551f/html5/thumbnails/51.jpg)
Many thanks to Samuel @smaftoul Maftoul, organiser of theParis DevOps meetup, who bootstrapped me on DevOps!