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

Reproducible work environments

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

Reproducible work environments

Avatar for Jan Schulte

Jan Schulte

April 02, 2015
Tweet

More Decks by Jan Schulte

Other Decks in Programming

Transcript

  1. • Complete setup installed on your machine • Ruby •

    Rails • Postgres / MySQL • RabbitMQ • …
  2. – The client from two months ago “We now would

    like to have feature X implemented”
  3. “Works on my machine” but not in production On your

    machine you have • a different operating system • a different file system • a different configuration (Users, Permissions, Services, …) than in production
  4. • You may have different errors on your dev machine

    than in production • How do you fix issues occurring in production only?
  5. Installed on my dev machine • Text editor / IDE

    • git • Vagrant • Virtualbox / VMWare
  6. It starts with dotfiles • The first thing you clone

    into your dev environment • Including • git • text editor (vim, Emacs, TextMate, …) • shell • …
  7. • Reproducible and portable development environments • Vagrantfile describes your

    machine • vagrant up to start the virtual machine • vagrant destroy when you’re done
  8. Disposable environments • Easy recovery when you break something •

    vagrant destroy -f && vagrant up • Automated setup of development environment with provisioners
  9. • Bring DEV closer to PRD environment • Infrastructure changes

    in version control • Infrastructure setup is documented • Spend less time for setup later on
  10. Vagrant.configure(2) do |config|
 config.vm.box = "chef/ubuntu-14.04" config.vm.network "private_network", ip: "192.168.33.10"

    config.vm.synced_folder "../../My_Project", "/vagrant" config.ssh.forward_agent = true
 config.vm.provision "puppet" do |puppet| puppet.manifests_path = "manifests" puppet.manifest_file = "nodes.pp" puppet.module_path = ["modules"] end end
  11. • Prepare development box • Run scripts to • Install

    packages • configure environment (Users, Permissions, Services, …) • Describe the final state you want • Let the provisioner figure out how to accomplish this
  12. # -*- mode: ruby -*-
 # vi: set ft=ruby :

    VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "chef/ubuntu-14.04" config.vm.provision "shell", path: "provision.sh" end
  13. # install a ruby wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz ./configure
 make && make

    install 
 # Install Postgresql apt-get install postgresql postgresql-contrib service postgresql start
  14. Niman • I wrote my own provisioner • https://github.com/schultyy/niman •

    Vagrant plugin • vagrant plugin install niman • No need to learn a new language • It’s just plain Ruby • Do not use this in production
  15. #Nimanfile Niman::Recipe.configure do |config| config.file '/home/bob/hello.txt' do |file| file.content =

    'hello from alice’ end config.package do |package| package.name = 'vim' end end
  16. # -*- mode: ruby -*-
 # vi: set ft=ruby :

    VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "chef/ubuntu-14.04" config.vm.provision "niman" end