Using Chef and Vagrant at Gengo

681 views
529 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
681
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Using Chef and Vagrant at Gengo

  1. 1. Chef and VagrantDerek Szydlowski & Yosuke Tomita
  2. 2. 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
  3. 3. Chef and it’s recipe connects many things….
  4. 4. ● Dev - Ops ● Production - Local ● English - Japanese
  5. 5. ● Dev - Ops ● Production - Local ● English - Japanese
  6. 6. Ops Dev
  7. 7. Many many talks about it.. DevOpsの今とこれから https://speakerdeck.com/naoya/devopsfalsejin-tokorekara-number-init-devops 10 + deploys per day Dev & ops coorporation at Flickr http://www.slideshare.net/jallspaw/10-deploys-per-day-dev-and-ops-cooperation-at-flickr
  8. 8. https://github.com/gengo/devops-tools How about Gengo??
  9. 9. (Team Leader) Contributor
  10. 10. Bottom up
  11. 11. ● Dev - Ops ● Production - Local ● English - Japanese
  12. 12. Local Production
  13. 13. 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).
  14. 14. Production Knife solo nodes/hoge1.fuga.com.json { "run_list": [ "role[api]" ], "environment": "prod", "n_fqdn": "hoge1.fuga.com", "server_name": "api-live" } roles/api.rb run_list( "role[base]", "recipe[nginx]", "recipe[python]", "recipe[repos::api]", "recipe[monit]", "recipe[monit::nginx]", "recipe[monit::api]" ) Local(Vagrant) vagrant-omnibus Vagrantfile config.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
  15. 15. Knife solo knife solo cook ubuntu@hoge1.fuga.com && knife solo cook ubuntu@hoge2.fuga.com daidokoro -> project-name nodes -> server information roles -> define role (web server, db etc..) cookbooks -> recipes data_bags -> store password etc..
  16. 16. nodes nodes/hoge1.fuga.com.json { "run_list": [ "role[api]" ], "environment": "prod", "n_fqdn": "hoge1.fuga.com", "server_name": "hoge1" }
  17. 17. roles roles/api.rb run_list( "role[base]", "recipe[nginx]", "recipe[python]", "recipe[repos::api]", "recipe[monit]", "recipe[monit::nginx]", "recipe[monit::api]" )
  18. 18. cookbooks cookbooks/repos/api.rb - install required module for application (apt-get) - setting virtualenv and install required package - add start/stop shell - restart service
  19. 19. 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 Vagrantfile config.vm.provision :chef_solo do |chef| chef.add_recipe "redis" chef.add_recipe "apache" end
  20. 20. 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
  21. 21. 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 'git@github.com: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 "git@github.com: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
  22. 22. ● Dev - Ops ● Production - Local ● English - Japanese
  23. 23. Japanese English
  24. 24. 日本人はドキュメント作って、 忠実に実行することが得意だから、 Chef のようなツールが浸透しない (らしい) ↓ Gengoは、、、、 + 言葉の壁、、、
  25. 25. 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)
  26. 26. Chef connects…. ● Dev - Ops ● Production - Local ● English - Japanese and more!!!

×