Vagrant + chef's cookbooks development environment like the production in few steps

23
Development environment like the production in few steps

Transcript of Vagrant + chef's cookbooks development environment like the production in few steps

Page 2: Vagrant + chef's cookbooks   development environment like the production in few steps

@tiagobutzke

● Software Engineer

● Founder and CEO at Stoodos.com

● Classic rock lover

● LP collector

● Beer and coffee drinker

Page 3: Vagrant + chef's cookbooks   development environment like the production in few steps

● “Development environments made easy”

● Roughly speaking, it's a way of control a VM via command line

Page 4: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to start vagrant (1)

Download and install virtual boxwww.virtualbox.org/wiki/Downloads

Page 6: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to start vagrant (3)

Add a new boxwww.vagrantbox.es

eg.: $ vagrant box add lucid32 http://files.vagrantup.com/lucid32.box

Page 7: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to start vagrant (4)

$ vagrant init

Page 8: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to start vagrant (5)

Config VagrantFile

eg.: config.vm.box = “lucid32” # the box that we installed in step 3, remember?

Page 9: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to start vagrant (6)

$ vagrant up

Page 11: Vagrant + chef's cookbooks   development environment like the production in few steps

Key Commands● $ vagrant up: starts the VM● $ vagrant suspend: save the machine state

and shut down the VM● $ vagrant ssh: Access VM via SSH● $ vagrant provision: Re-runs provision config

and start● $ vagrant reload: Reset VM● $ vagrant destroy: Remove VM

Page 12: Vagrant + chef's cookbooks   development environment like the production in few steps

● “IT automation for speed and awesomeness”

● Roughly speaking, it's a way to automate your environment build and config using ruby

Page 13: Vagrant + chef's cookbooks   development environment like the production in few steps

CookbooksIt's a ruleset that tell Chef how to install

something

Page 14: Vagrant + chef's cookbooks   development environment like the production in few steps

Cookbooks

● You can develop your own cookbooks

● In Github you can find several cookbooks ready to use

Page 15: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to add cookbooks ready (1)

Directories

eg.: $ mkdir -p {cookbooks, data_bags, roles}

Page 16: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to add cookbooks ready (2)

Config VagrantFile

config.vm.provision :chef_solo do |chef| chef.cookbooks_path = “cookbooks” chef.data_bags_pash = “data_bags” chef.roles_path = “roles” chef.add_role = “default”end

Page 17: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to add cookbooks ready (3)

Init git

$ git init .

Page 18: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to add cookbooks ready (4)

Add a cookbook

eg.: $ git submodule add https://github.com/opscode-cookbooks/apt.git cookbooks/apt

Page 19: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to add cookbooks ready (5)

Create default roles (file roles/defaylt.rb)

name “deafult”run_list( “recipe[apt]”)

Page 20: Vagrant + chef's cookbooks   development environment like the production in few steps

Steps to add cookbooks ready (6)

Provision

If VM exists: $ vagrant provisionIf not: $ vagrant up

Page 22: Vagrant + chef's cookbooks   development environment like the production in few steps

Be happy!