Primeiros Passos com Chef

548 views

Published on

Um workshop para quem está começando com a ferramenta Opscode Chef.
Apresentado no Idéias em Produção, em 21 de Abril de 2013 no escritório da ThoughtWorks Brasil em Porto Alegre.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
548
On SlideShare
0
From Embeds
0
Number of Embeds
23
Actions
Shares
0
Downloads
10
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Primeiros Passos com Chef

  1. 1. primeiros passoscom CHEF@cassianolealSunday, April 21, 13
  2. 2. ?CHEFMas afinal,o que éSunday, April 21, 13
  3. 3. Sunday, April 21, 13
  4. 4. Sunday, April 21, 13
  5. 5. RUBYinSunday, April 21, 13
  6. 6. knifeé a ferramenta de linhade comando do Chefworkstationna suaSunday, April 21, 13
  7. 7. workstationsetupGitVagrantVirtualBoxRubyChefSunday, April 21, 13
  8. 8. $ vagrant box add opscode-ubuntu1204 http://<ip>:8000/opscode_ub1204.boxDownloading or copying the box...Extracting box...te: 280M/s, Estimated time remaining: 0:00:01)Successfully added box opscode-ubuntu1204 with providervirtualbox!Sunday, April 21, 13
  9. 9. REPOChefgit clone git://github.com/opscode/chef-repocertificates/.chef/config/cookbooks/data_bags/environments/roles/Sunday, April 21, 13
  10. 10. knife.rb.chef/current_path = File.expand_path(File.dirname(__FILE__))cookbook_path [ "#{current_path}/../cookbooks" ]Sunday, April 21, 13
  11. 11. $ knife cookbook create my_app$ cd cookbooks/my_app$ lsSunday, April 21, 13
  12. 12. COOKBOOKmy_appCHANGELOG.mdREADME.mdattributes/definitions/files/libraries/metadata.rbproviders/recipes/resources/templates/Sunday, April 21, 13
  13. 13. COOKBOOKmy_appCHANGELOG.mdREADME.mdattributes/definitions/files/libraries/metadata.rbproviders/recipes/resources/templates/Sunday, April 21, 13
  14. 14. default.rbrecipes/package ‘apache2’directory “/var/www/my_app” doowner ‘www-data’group ‘www-data’mode 0755action :createendSunday, April 21, 13
  15. 15. $ vagrant init opscode_ubuntu1204Sunday, April 21, 13
  16. 16. VagrantfileVagrant.configure("2") do |config|config.vm.box = "opscode_ubuntu1204"config.vm.provision :chef_solo do |chef|chef.cookbooks_path = "../../cookbooks"chef.add_recipe "my_app::default"endendSunday, April 21, 13
  17. 17. $ vagrant up(...)======================================================Error executing action `install` on resource package[apache2]======================================================Chef::Exceptions::Exec----------------------apt-get -q -y install apache2=2.2.22-1ubuntu1.2 returned 100, expected 0(...)Sunday, April 21, 13
  18. 18. $ vagrant ssh$ sudo apt-get -q -y install apache2=2.2.22-1ubuntu1.2Sunday, April 21, 13
  19. 19. execute "update apt cache" docommand "apt-get update"user rootaction :runendSunday, April 21, 13
  20. 20. SERVERChefhttps://community.opscode.com/users/newSunday, April 21, 13
  21. 21. [your_organization_name]-validator.pem[your_username].pemknife.rbREPOChefgit clone git://github.com/opscode/chef-repo$ knife client listSunday, April 21, 13
  22. 22. http://community.opscode.com/cookbooks/COMMUNITYwebsiteSunday, April 21, 13
  23. 23. $ knife cookbook site install apache2$ git status# On branch master# Your branch is ahead of origin/master by 1 commit.# (use "git push" to publish your local commits)## Untracked files:# (use "git add <file>..." to include in what will be committed)## .chef/nothing added to commit but untracked files present (use "git add" to track)Sunday, April 21, 13
  24. 24. GITlogSunday, April 21, 13
  25. 25. berkshelfBUNDLERpara cookbooks$ gem install berkshelfSunday, April 21, 13
  26. 26. Berksfilesite :opscodecookbook aptcookbook apache2$ berks install$ berks uploadSunday, April 21, 13
  27. 27. $ knife cookbook create my_appSunday, April 21, 13
  28. 28. default.rbrecipes/directory “#{node[:my_app][:root]}/my_app” doowner node[:apache][:user]group node[:apache][:group]mode 0755action :createendSunday, April 21, 13
  29. 29. chef-repo/roles/my_app.rbname my_appdescription A single application serverrun_list(recipe[apt::default],recipe[apache2::default],recipe[my_app])Sunday, April 21, 13
  30. 30. $ knife cookbook upload my_app$ knife role from file roles/my_app.rb$ knife cookbook list$ knife role list$ knife role show my_appSunday, April 21, 13
  31. 31. TemplatesNode AttributesSearchBootstrapService / Notifies2 caminhos:- alguém sugere o que fazer- seguir o learnchef EC2LWRPSunday, April 21, 13
  32. 32. https://learnchef.opscode.comhttp://docs.opscode.comhttp://community.opscode.comhttps://manage.opscode.comhttp://lists.opscode.com/sympairc.freenode.com #chefeagora?Sunday, April 21, 13

×