Upload
gengo
View
350
Download
4
Tags:
Embed Size (px)
DESCRIPTION
Citation preview
Chef and
Vagrant Derek Szydlowski&
Yosuke Tomita
I’ll Talk about how I feel about using chef,how we use chef.
(not what is chef, not why start using chef) -> Derek will talk the second part in Devops Day, 9/28
Chef and it’s recipe connects many things….
● Dev - Ops● Production - Local● English - Japanese
● Dev - Ops● Production - Local● English - Japanese
Ops
Dev
Many many talks about it..
DevOpsの今とこれからhttps://speakerdeck.com/naoya/devopsfalsejin-tokorekara-number-init-devops
10 + deploys per dayDev & ops coorporation at Flickrhttp://www.slideshare.net/jallspaw/10-deploys-per-day-dev-and-ops-cooperation-at-flickr
https://github.com/gengo/devops-tools
How about Gengo??
(Team Leader)
Contributor
Bottom up
● Dev - Ops● Production - Local● English - Japanese
Local
Production
Develop Flow (for new application)
1. Develop in local.
2. Create recipe.
3. Test on QA env, both appication and recipe.
4. Deploy to Production using chef.
5. Make it work in local env(Vagrant).
ProductionKnife solonodes/hoge1.fuga.com.json{ "run_list": [ "role[api]" ], "environment": "prod", "n_fqdn": "hoge1.fuga.com", "server_name": "api-live"}
roles/api.rbrun_list( "role[base]", "recipe[nginx]", "recipe[python]", "recipe[repos::api]", "recipe[monit]", "recipe[monit::nginx]", "recipe[monit::api]")
Local(Vagrant)vagrant-omnibusVagrantfileconfig.vm.provision :chef_solo do |chef|
chef.add_recipe "nginx"chef.add_recipe "php_pack"chef.add_recipe "base::git"chef.add_recipe "repos::dev_repos"chef.add_recipe "python" chef.add_recipe "repos::api"
end
Knife soloknife solo cook [email protected]&& knife solo cook [email protected]
daidokoro -> project-name nodes -> server information roles -> define role (web server, db etc..) cookbooks -> recipes data_bags -> store password etc..
nodes
nodes/hoge1.fuga.com.json{ "run_list": [ "role[api]" ], "environment": "prod", "n_fqdn": "hoge1.fuga.com", "server_name": "hoge1"}
roles
roles/api.rb
run_list( "role[base]", "recipe[nginx]", "recipe[python]", "recipe[repos::api]", "recipe[monit]", "recipe[monit::nginx]", "recipe[monit::api]")
cookbooks
cookbooks/repos/api.rb
- install required module for application (apt-get)- setting virtualenv and install required package- add start/stop shell- restart service
Vagrant omnibus
A Vagrant plugin that ensures the desired version of Chef is installed https://github.com/schisamo/vagrant-omnibus
don’t need to “knife solo prepare”
in Vagrantfileconfig.vm.provision :chef_solo do |chef|
chef.add_recipe "redis"chef.add_recipe "apache"
end
difference between local and prod
- port setting use “template” resource
template "#{virtual_env}/bin/api_start.sh" do source "api_start.sh.erb" owner "deployer" group "www-data" mode 0655 variables({ :env => node['environment'], :port => node['repos']['api_port'] })end
difference between local and prod
- deploy use “deploy” resource for prod, use “git” resource for dev
deploy "/mnt#{node['repos']['home']}/#{project}" do ssh_wrapper "/tmp/private_code/wrap-ssh4git.sh" repo '[email protected]:gengo/api' branch "#{node['repos']['branch']}" keep_releases 3 user "deployer" group "www-data" create_dirs_before_symlink [] symlink_before_migrate.clear symlinks.clear symlinks "bin" => "bin" notifies :restart, "service[#{project}]"end
http://docs.opscode.com/resource.html
git "#{node['repos']['home']}/#{project}" do repository "[email protected]:gengo/api.git" ssh_wrapper "/tmp/private_code/wrap-ssh4git.sh" action :checkout notifies :restart, "service[#{project}]" end
http://docs.opscode.com/resource_git.html
● Dev - Ops● Production - Local● English - Japanese
Japanese
English
日本人はドキュメント作って、忠実に実行することが得意だから、Chef のようなツールが浸透しない(らしい)
↓
Gengoは、、、、+ 言葉の壁、、、
Can review the code if can’t hear well.
Can explain with code if can’t speak well.
No (less?) manual operation on a server.<- When Running the same recipe in next release, the change can be lost.
Infrastructure as code (for me)
Chef connects….
● Dev - Ops● Production - Local● English - Japanese
and more!!!