vagrant + chef's cookbooks development environment like the production in few steps
TRANSCRIPT
![Page 1: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/1.jpg)
Development environment like the production in few steps
![Page 2: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/2.jpg)
@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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/3.jpg)
● “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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/4.jpg)
Steps to start vagrant (1)
Download and install virtual boxwww.virtualbox.org/wiki/Downloads
![Page 5: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/5.jpg)
Steps to start vagrant (2)
Download and install vagrantvagrantup.com/downloads.html
![Page 6: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/6.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/7.jpg)
Steps to start vagrant (4)
$ vagrant init
![Page 8: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/8.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/9.jpg)
Steps to start vagrant (6)
$ vagrant up
![Page 10: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/10.jpg)
Steps to start vagrant (7)
![Page 11: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/11.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/12.jpg)
● “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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/13.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/14.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/15.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/16.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/17.jpg)
Steps to add cookbooks ready (3)
Init git
$ git init .
![Page 18: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/18.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/19.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/20.jpg)
Steps to add cookbooks ready (6)
Provision
If VM exists: $ vagrant provisionIf not: $ vagrant up
![Page 21: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/21.jpg)
Steps to add cookbooks ready (7)
![Page 22: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/22.jpg)
Be happy!
![Page 23: Vagrant + chef's cookbooks development environment like the production in few steps](https://reader035.vdocument.in/reader035/viewer/2022081403/554a3493b4c90582328b456b/html5/thumbnails/23.jpg)
Tiago Butzke
@tiagobutzke
github.com/tiagobutzke
linkedin.com/in/tiagobutzke