Top Banner
22

Devops days

May 06, 2015

Download

Technology

Gengo

Presentation by Yosuke Tomita and Derek Szydlowski at DevOps Days Tokyo '13
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Devops days
Page 2: Devops days

Our love for Chef and Vagrant Derek Szydlowski

&Yosuke Tomita

Page 3: Devops days

Our setupWhy Chef and vagrant - Challenges

Starting project Knife vs Vagrant (Solo)Best practice/code to define recipes for multiple environments

Problems with Vagrant / ChefDevelopment Flow

Recap and why it’s good for international office.More external info sources add chef and vagrant link

OUTLINE

Page 4: Devops days

Intro

Page 5: Devops days

60 + production servers ( 120 total )3 + environments

50 + repos15 + active contributors

Page 6: Devops days

Challenges

Page 7: Devops days

作業記録なし

Manual Environments = Unstable unscalable environments

バラバラな環境

CHALLENGE 1

テスト不可

単調な作業 の連続 → 人為的ミス

Page 8: Devops days

Devs and Devops not in syncChef meets Vagrant

CHALLENGE 2

開発者は実装にのみ集中しがち

Opsの作業時間がタスクに含まれていない

新メンバーが入った時、新しい技術を入れた時の環境構築が大変

Page 9: Devops days

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

Page 10: Devops days

Workflow

Page 11: Devops days

Outline

Page 12: Devops days

Development Flow

Page 13: Devops days

Code Example

Let’s dip into the code and see some ways to create a dev vs production server.

Page 14: Devops days

Production/QAKnife-Solo

roles/api.rbrun_list(

"role[base]",

"recipe[nginx]",

"recipe[python]",

"recipe[repos::api]", "recipe[monit]",

"recipe[monit::nginx]",

"recipe[monit::api]"

)

LocalVagrant

Vagrantfileconfig.vm.provision :chef_solo do |chef|

chef.add_recipe "base::git"

chef.add_recipe "nginx"

chef.add_recipe "php_pack"

chef.add_recipe "python"

chef.add_recipe "repos::api" end

Sharing recipe on local and servers

Page 15: Devops days

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”

Page 16: Devops days

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”

Page 17: Devops days

Changing Resource in a Recipe.

cookbooks/repos/recipes/api

if node['environment'] == "dev" 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}]" endelse deploy "/mnt#{node['repos']['home']}/#{project}" do ssh_wrapper "/tmp/private_code/wrap-ssh4git.sh" repo '[email protected]:gengo/api' branch "#{node['repos']['branch']}" migrate false keep_releases 3 notifies :restart, "service[#{project}]" endend

Define in “node/xxx.json” or“Vagrantfile”

Page 18: Devops days

Hurdles

Page 19: Devops days

Chef and Vagrant Hurdles!

opsもコードに強くなる必要がある → Devと一緒にやると距離が縮まる

devになかなか使ってもらえない

様々な開発環境(Window, Mac, Ubuntu….)

バグを踏むこともある  → コミュニティ

Page 20: Devops days

Bonus!

Page 21: Devops days

Any Questions?

Name 3 languages that Gengo has client library for?

@gengo, @gengo_ja

https://github.com/gengo

http://gengo.doorkeeper.jp

Page 22: Devops days