Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Chef for the Symfony developer

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Avatar for Carlos Mafla Carlos Mafla
November 12, 2016

Chef for the Symfony developer

Chef has become one of the most popular frameworks to automate infrastructure using code, it's being used by big companies like Facebook but you don't need to have a large infrastructure to benefit from it. This is an introductory talk to Chef but also the result of my experience using Chef for a couple years with Symfony projects.

Avatar for Carlos Mafla

Carlos Mafla

November 12, 2016

More Decks by Carlos Mafla

Other Decks in Programming

Transcript

  1. About Me • Web Developer (Backend, DevOps, Frontend developer, etc

    ) • 10+ years of working with PHP • 5+ years of working with Symfony • Scalable Path • @gigo6000 • github.com/gigo6000
  2. apt-get install apache2 apt-get install php5 php5-curl … yum install

    httpd yum install php php-curl … lots of clicks on “Next” buttons… brew install httpd24 …
  3. Why use Chef? • Consistency between environments • Automation •

    Versionable/Reusable infrastructure code • It’s used by Facebook, Airbnb, Mozilla, etc, etc • Setting up a local environment could take minutes not hours or days
  4. Chef Terms • Nodes • Workstation • Recipes • Cookbooks

    • Attributes • Environments • Roles • Data Bags • Knife • Berkshelf • Chef Supermarket
  5. Cookbook = - my-cookbook - attributes - metadata.rb - providers

    - recipes - resources - templates - apache.rb - php.rb - mysql.rb - cronjobs.rb - etc
  6. Attributes = chef/cookbooks/mycookbook/attributes/default.rb cookbook Ruby : ”add to the end

    of this array" Similar to Symfony config file: config.yml
  7. Symfony2+Chef Project Structure - Berksfile - Berksfile.lock - app -

    bin - chef - src - vendor - web - cookbooks - data_bags - environments - roles - my-cookbook - attributes - metadata.rb - providers - recipes - resources - templates Chef Repo
  8. Chef Workstation Chef Server Chef Node Chef Node Chef Node

    Workflow Knife Berks cookbook Chef Client Chef Client Chef Client data bags
  9. Callbacks •after_restart •before_migrate •before_restart •before_symlink php bin/vendors install php app/console

    cache:warmup php app/console assets:install web php app/console assetic:dump web deploy/before_migrate.rb https://docs.chef.io/resource_deploy.html Similar to Capistrano
  10. Chef + Vagrant Vagrantfile Requires vagrant-berkshelf plugin Path to chef

    repo Change document root to /vagrant Roles/Recipes that will be installed Use Chef Solo to provision
  11. • Your server will be deleted • You need to

    replace it if it doesn’t start again • Make sure you are backing up your database in PROD • You should be able to recreate anything on the server: bash scripts, assets, cronjobs, etc 
 What this means?
  12. Conclusion • If you are using AWS and you are

    not using Chef you should be worried • Use any provisioning tool if aren’t using one • Try Chef + Vagrant for your local environment