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

Development with Ansible & VMs

Jeff Schenck
September 02, 2014

Development with Ansible & VMs

Presented at DjangoCon US 2014

How do you set up a kick-ass dev environment? I'll share our team's setup and tools that give us a dev environment with superpowers: mirrors production; sets itself up with a single command; documented in code; repeatable and shareable. I hope you learn something you can put into action tomorrow!

Jeff Schenck

September 02, 2014
Tweet

More Decks by Jeff Schenck

Other Decks in Technology

Transcript

  1. Development with Ansible & VMs OUTLINE 1. BETTER DEV 2.

    ENVIRONMENT TOOLS 3. CONFIG TOOLS 4. WRAP-UP
  2. Development with Ansible & VMs DEV WISH LIST • Standardized

    • Repeatable • Isolated • Production-like
  3. Development with Ansible & VMs DEV WISH LIST • Standardized

    • Repeatable • Isolated • Production-like • Your tools
  4. Development with Ansible & VMs DEV WISH LIST • Standardized

    • Repeatable • Isolated • Production-like • Your tools • Shareable
  5. Development with Ansible & VMs VM • Isolates entire box

    • Python packages • System packages
  6. Development with Ansible & VMs VM • Isolates entire box

    • Python packages • System packages • Production-like
  7. Development with Ansible & VMs VM SETUP $ vagrant init

    hashicorp/precise64! $ vagrant up! $ vagrant ssh
  8. Development with Ansible & VMs VM SETUP Vagrant::configure("2") do |config|!

    config.vm.box = "hashicorp/precise64"! config.vm.hostname = "chewse"! config.vm.network "private_network", ip: "10.0.0.100"! ! config.vm.provision "ansible" do |ansible|! ansible.playbook = "ansible/chewse.yml"! end! end!
  9. Development with Ansible & VMs VM SETUP Vagrant::configure("2") do |config|!

    config.vm.box = "hashicorp/precise64"! config.vm.hostname = "chewse"! config.vm.network "private_network", ip: "10.0.0.100"! ! config.vm.provision "ansible" do |ansible|! ansible.playbook = "ansible/chewse.yml"! end! end!
  10. Development with Ansible & VMs VM SETUP Vagrant::configure("2") do |config|!

    config.vm.box = "hashicorp/precise64"! config.vm.hostname = "chewse"! config.vm.network "private_network", ip: "10.0.0.100"! ! config.vm.provision "ansible" do |ansible|! ansible.playbook = "ansible/chewse.yml"! end! end!
  11. Development with Ansible & VMs VM SETUP Vagrant::configure("2") do |config|!

    config.vm.box = "hashicorp/precise64"! config.vm.hostname = "chewse"! config.vm.network "private_network", ip: "10.0.0.100"! ! config.vm.provision "ansible" do |ansible|! ansible.playbook = "ansible/chewse.yml"! end! end!
  12. Development with Ansible & VMs VM SETUP Vagrant::configure("2") do |config|!

    config.vm.box = "hashicorp/precise64"! config.vm.hostname = "chewse"! config.vm.network "private_network", ip: "10.0.0.100"! ! config.vm.provision "ansible" do |ansible|! ansible.playbook = "ansible/chewse.yml"! end! end!
  13. Development with Ansible & VMs 3. CONFIG TOOLS 1. BETTER

    DEV 2. ENVIRONMENT TOOLS 4. WRAP-UP
  14. Development with Ansible & VMs CONFIGURATION • Defines system setup

    • Written in code • Documented and versioned
  15. Development with Ansible & VMs CONFIGURATION • Defines system setup

    • Written in code • Documented and versioned • Shareable
  16. Development with Ansible & VMs CONFIGURATION SETUP - name: standard

    python system packages! apt: pkg={{ item }} state=installed! with_items:! - python! - python-dev! - python-pip! - libxml2-dev! - libxslt1-dev! sudo: yes! ! - name: bootstrap pip and virtualenv! pip: name={{ item.name }} version={{ item.version }}! with_items:! - { name: pip, version: 1.4.1 }! - { name: virtualenv, version: 1.10.1 }! sudo: yes! ! - name: install requirements.txt! pip: requirements=/vagrant/requirements.txt virtualenv=/var/venv! sudo: yes! ! - name: source virtualenv in .bashrc! lineinfile: dest=/home/vagrant/.bashrc line="{{ item }}"! with_items:! - source /var/venv/bin/activate! - cd /vagrant/chewse!
  17. Development with Ansible & VMs CONFIGURATION SETUP - name: standard

    python system packages! ...! ! - name: bootstrap pip and virtualenv! ...! ! - name: install requirements.txt! ...! ! - name: source virtualenv in .bashrc! ...
  18. Development with Ansible & VMs CONFIGURATION SETUP - name: standard

    python system packages! apt: pkg={{ item }} state=installed! with_items:! - python! - python-dev! - python-pip! - libxml2-dev! - libxslt1-dev! sudo: yes
  19. Development with Ansible & VMs CONFIGURATION SETUP - name: standard

    python system packages! apt: pkg={{ item }} state=installed! with_items:! - python! - python-dev! - python-pip! - libxml2-dev! - libxslt1-dev! sudo: yes
  20. Development with Ansible & VMs CONFIGURATION SETUP - name: standard

    python system packages! apt: pkg={{ item }} state=installed! with_items:! - python! - python-dev! - python-pip! - libxml2-dev! - libxslt1-dev! sudo: yes
  21. Development with Ansible & VMs CONFIGURATION SETUP - name: standard

    python system packages! apt: pkg={{ item }} state=installed! with_items:! - python! - python-dev! - python-pip! - libxml2-dev! - libxslt1-dev! sudo: yes
  22. Development with Ansible & VMs CONFIGURATION SETUP - name: bootstrap

    pip and virtualenv! pip: name={{ item.name }} version={{ item.version }}! with_items:! - { name: pip, version: 1.4.1 }! - { name: virtualenv, version: 1.10.1 }! sudo: yes!
  23. Development with Ansible & VMs CONFIGURATION SETUP - name: bootstrap

    pip and virtualenv! pip: name={{ item.name }} version={{ item.version }}! with_items:! - { name: pip, version: 1.4.1 }! - { name: virtualenv, version: 1.10.1 }! sudo: yes!
  24. Development with Ansible & VMs CONFIGURATION SETUP - name: bootstrap

    pip and virtualenv! pip: name={{ item.name }} version={{ item.version }}! with_items:! - { name: pip, version: 1.4.1 }! - { name: virtualenv, version: 1.10.1 }! sudo: yes!
  25. Development with Ansible & VMs CONFIGURATION SETUP - name: install

    requirements.txt! pip: requirements=/vagrant/requirements.txt ! virtualenv=/var/venv! sudo: yes!
  26. Development with Ansible & VMs CONFIGURATION SETUP - name: install

    requirements.txt! pip: requirements=/vagrant/requirements.txt ! virtualenv=/var/venv! sudo: yes!
  27. Development with Ansible & VMs CONFIGURATION SETUP - name: source

    virtualenv in .bashrc! lineinfile: dest=/home/vagrant/.bashrc line="{{ item }}"! with_items:! - source /var/venv/bin/activate! - cd /vagrant/chewse!
  28. Development with Ansible & VMs CONFIGURATION SETUP - name: source

    virtualenv in .bashrc! lineinfile: dest=/home/vagrant/.bashrc line="{{ item }}"! with_items:! - source /var/venv/bin/activate! - cd /vagrant/chewse!
  29. Development with Ansible & VMs CONFIGURATION SETUP - name: source

    virtualenv in .bashrc! lineinfile: dest=/home/vagrant/.bashrc line="{{ item }}"! with_items:! - source /var/venv/bin/activate! - cd /vagrant/chewse!
  30. Development with Ansible & VMs CONFIGURATION SETUP - name: standard

    python system packages! apt: pkg={{ item }} state=installed! with_items:! - python! - python-dev! - python-pip! - libxml2-dev! - libxslt1-dev! sudo: yes! ! - name: bootstrap pip and virtualenv! pip: name={{ item.name }} version={{ item.version }}! with_items:! - { name: pip, version: 1.4.1 }! - { name: virtualenv, version: 1.10.1 }! sudo: yes! ! - name: install requirements.txt! pip: requirements=/vagrant/requirements.txt virtualenv=/var/venv! sudo: yes! ! - name: source virtualenv in .bashrc! lineinfile: dest=/home/vagrant/.bashrc line="{{ item }}"! with_items:! - source /var/venv/bin/activate! - cd /vagrant/chewse!
  31. Development with Ansible & VMs 4. WRAP-UP 1. BETTER DEV

    2. ENVIRONMENT TOOLS 3. CONFIG TOOLS
  32. Development with Ansible & VMs OUR INSTALL • Install VirtualBox

    and Vagrant • Git clone chewse • Vagrant up
  33. Development with Ansible & VMs OUR INSTALL • Install VirtualBox

    and Vagrant • Git clone chewse • Vagrant up • Dev nirvana
  34. Development with Ansible & VMs DEV WISH LIST • Standardized

    • Repeatable • Isolated • Production-like
  35. Development with Ansible & VMs DEV WISH LIST • Standardized

    • Repeatable • Isolated • Production-like • Your tools
  36. Development with Ansible & VMs DEV WISH LIST • Standardized

    • Repeatable • Isolated • Production-like • Your tools • Shareable
  37. Development with Ansible & VMs Jeff Schenck CTO & Co-Founder

    twitter @jeffschenck slides bit.ly/dev-ansible-vm