3. Our setup
Why Chef and vagrant - Challenges
Starting project Knife vs Vagrant (Solo)
Best practice/code to define recipes for multiple environments
Problems with Vagrant / Chef
Development Flow
Recap and why it’s good for international office.
More external info sources add chef and vagrant link
OUTLINE
8. Devs and Devops not in sync
Chef meets Vagrant
CHALLENGE 2
開発者は実装にのみ集中しがち
Opsの作業時間がタスクに含まれていない
新メンバーが入った時、新しい技術を入れた時の
環境構築が大変
9. Chef / Chef-Solo: configuration management
tool
Chef Recipe/Cookbook: Chef configuration file
AWS EC2: Virtual Machine Cloud Service
VirtualBox: Virtual Machine for Local
Environments
Vagrant: wrapper for creating VirtualMachines,
delivering chef
recipes and runs Chef remotely
Knife-solo: Delivers recipes and runs chef
remotely.
Words and Terms
15. Changing server configuration in a template
cookbooks/repos/templates/api.erb
------
<%- case node[‘environment'] %>
<%- when "live" %>
api_url = 'http://api.gengo.com'
<%- when "qa" %>
api_url = 'http://yyy.api.gengo.com'
<%- when "dev" %>
api_url = 'http://xxx.api.gengo.com'
<%- end %>
------
Define in “node/xxx.json
or
Vagrantfile”
16. Changing server configuration via Attributes
cookbooks/repos/attributes/default.rb
------
if node['environment'] == 'live'
default['repos']['gengo_database'] = "database_live"
default[‘repos’][‘nginx_security_password’] = “true”
elseif node['environment'] == 'qa'
default['repos']['gengo_database'] = "database_qa"
default[‘repos’][‘nginx_security_password’] = “false”
------
cookbooks/repos/templates/api.erb
------
database = ‘<%= default['repos']['gengo_database'] %>’
------
Define in “node/xxx.json”
or
“Vagrantfile”
17. Changing Resource in a Recipe.
cookbooks/repos/recipes/api
if node['environment'] == "dev"
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
else
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']}"
migrate false
keep_releases 3
notifies :restart, "service[#{project}]"
end
end
Define in “node/xxx.json”
or
“Vagrantfile”