+ All Categories
Home > Technology > Using Chef and Vagrant at Gengo

Using Chef and Vagrant at Gengo

Date post: 13-Jan-2015
Category:
Upload: gengo
View: 350 times
Download: 4 times
Share this document with a friend
Description:
 
Popular Tags:
26
Chef and Vagrant Derek Szydlowski & Yosuke Tomita
Transcript
Page 1: Using Chef and Vagrant at Gengo

Chef and

Vagrant Derek Szydlowski&

Yosuke Tomita

Page 2: Using Chef and Vagrant at Gengo

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

Page 3: Using Chef and Vagrant at Gengo

Chef and it’s recipe connects many things….

Page 4: Using Chef and Vagrant at Gengo

● Dev - Ops● Production - Local● English - Japanese

Page 5: Using Chef and Vagrant at Gengo

● Dev - Ops● Production - Local● English - Japanese

Page 6: Using Chef and Vagrant at Gengo

Ops

Dev

Page 7: Using Chef and Vagrant at Gengo

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

Page 8: Using Chef and Vagrant at Gengo

https://github.com/gengo/devops-tools

How about Gengo??

Page 9: Using Chef and Vagrant at Gengo

(Team Leader)

Contributor

Page 10: Using Chef and Vagrant at Gengo

Bottom up

Page 11: Using Chef and Vagrant at Gengo

● Dev - Ops● Production - Local● English - Japanese

Page 12: Using Chef and Vagrant at Gengo

Local

Production

Page 13: Using Chef and Vagrant at Gengo

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).

Page 14: Using Chef and Vagrant at Gengo

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

Page 15: Using Chef and Vagrant at Gengo

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..

Page 16: Using Chef and Vagrant at Gengo

nodes

nodes/hoge1.fuga.com.json{ "run_list": [ "role[api]" ], "environment": "prod", "n_fqdn": "hoge1.fuga.com", "server_name": "hoge1"}

Page 17: Using Chef and Vagrant at Gengo

roles

roles/api.rb

run_list( "role[base]", "recipe[nginx]", "recipe[python]", "recipe[repos::api]", "recipe[monit]", "recipe[monit::nginx]", "recipe[monit::api]")

Page 18: Using Chef and Vagrant at Gengo

cookbooks

cookbooks/repos/api.rb

- install required module for application (apt-get)- setting virtualenv and install required package- add start/stop shell- restart service

Page 19: Using Chef and Vagrant at Gengo

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

Page 20: Using Chef and Vagrant at Gengo

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

Page 21: Using Chef and Vagrant at Gengo

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

Page 22: Using Chef and Vagrant at Gengo

● Dev - Ops● Production - Local● English - Japanese

Page 23: Using Chef and Vagrant at Gengo

Japanese

English

Page 24: Using Chef and Vagrant at Gengo

日本人はドキュメント作って、忠実に実行することが得意だから、Chef のようなツールが浸透しない(らしい)

Gengoは、、、、+ 言葉の壁、、、

Page 25: Using Chef and Vagrant at 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)

Page 26: Using Chef and Vagrant at Gengo

Chef connects….

● Dev - Ops● Production - Local● English - Japanese

and more!!!


Recommended