primeiros passos com chef
DESCRIPTION
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.TRANSCRIPT
!r"#$"r% !&''%()#CHEF
@cassianoleal
Sunday, April 21, 13
?CHEFM&' &*+&,,) q-$ .
Sunday, April 21, 13
Sunday, April 21, 13
Sunday, April 21, 13
RUBY"+
Sunday, April 21, 13
knife. & f$rr&#$+/& 0$ ,"+1&0$ ()#&+0) 0) C1$f
workstation+& '-&
Sunday, April 21, 13
workstation'$/-!Git
Vagrant
VirtualBox
Ruby
Chef
Sunday, April 21, 13
$ vagrant box add opscode-ubuntu1204 \http://<ip>:8000/opscode_ub1204.box
Downloading or copying the box...Extracting box...te: 280M/s, Estimated time remaining: 0:00:01)Successfully added box 'opscode-ubuntu1204' with provider 'virtualbox'!
Sunday, April 21, 13
REPOC1$f
git clone git://github.com/opscode/chef-repo
certificates/.chef/config/cookbooks/data_bags/environments/roles/
Sunday, April 21, 13
knife.rb.(1$f/
current_path = File.expand_path(File.dirname(__FILE__))cookbook_path [ "#{current_path}/../cookbooks" ]
Sunday, April 21, 13
$ knife cookbook create my_app
$ cd cookbooks/my_app
$ ls
Sunday, April 21, 13
COOKBOOK#2_&!!
CHANGELOG.mdREADME.mdattributes/definitions/files/libraries/metadata.rbproviders/recipes/resources/templates/
Sunday, April 21, 13
COOKBOOK#2_&!!
CHANGELOG.mdREADME.mdattributes/definitions/files/libraries/metadata.rbproviders/recipes/resources/templates/
Sunday, April 21, 13
default.rbr$("!$'/
package ‘apache2’
directory “/var/www/my_app” do owner ‘www-data’ group ‘www-data’ mode 0755 action :createend
Sunday, April 21, 13
$ vagrant init opscode_ubuntu1204
Sunday, April 21, 13
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" endend
Sunday, April 21, 13
$ 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
$ vagrant ssh$ sudo apt-get -q -y install apache2=2.2.22-1ubuntu1.2
Sunday, April 21, 13
execute "update apt cache" do command "apt-get update" user 'root' action :runend
Sunday, April 21, 13
SERVERC1$f
https://community.opscode.com/users/newSunday, April 21, 13
[your_organization_name]-validator.pem[your_username].pemknife.rb
REPOC1$f
git clone git://github.com/opscode/chef-repo
$ knife client listSunday, April 21, 13
http://community.opscode.com/cookbooks/
COMMUNITYw$3"/$
Sunday, April 21, 13
$ 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
GIT,)4
Sunday, April 21, 13
berkshelf
BUNDLER !&r& ())5b))5'
$ gem install berkshelf
Sunday, April 21, 13
Berksfilesite :opscodecookbook 'apt'cookbook 'apache2'
$ berks install$ berks upload
Sunday, April 21, 13
$ knife cookbook create my_app
Sunday, April 21, 13
default.rbr$("!$'/
directory “#{node[:my_app][:root]}/my_app” do owner node[:apache][:user] group node[:apache][:group] mode 0755 action :createend
Sunday, April 21, 13
chef-repo/roles/my_app.rb
name 'my_app'description 'A single application server'run_list( 'recipe[apt::default]', 'recipe[apache2::default]', 'recipe[my_app]')
Sunday, April 21, 13
$ knife cookbook upload my_app$ knife role from file roles/my_app.rb
$ knife cookbook list$ knife role list
$ knife role show my_app
Sunday, April 21, 13
Templates
N!"# A$$r%b&$#'
S#(r)*Bootstrap
S#rv%)# / N!$%+#'
2 caminhos:- alguém sugere o que fazer- seguir o learnchef EC2
LWRP
Sunday, April 21, 13
https://learnchef.opscode.comhttp://docs.opscode.comhttp://community.opscode.comhttps://manage.opscode.comhttp://lists.opscode.com/sympa
irc.freenode.com #chef
$agora?
Sunday, April 21, 13