Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
cooking infrastructure with chef
Mathias Meyer
May 13, 2013
Technology
4
210
cooking infrastructure with chef
An introduction to Chef with the simplest Chef that could possibly work.
Mathias Meyer
May 13, 2013
Tweet
Share
More Decks by Mathias Meyer
See All by Mathias Meyer
Building and Scaling an Distributed and Inclusive Team
roidrage
0
970
The Message Queue is Dead, Long Live the Message Queue
roidrage
4
600
riak-js
roidrage
1
260
designing for concurrency with riak
roidrage
11
1.6k
metrics, monitoring, logging
roidrage
82
14k
design for cloud - jax 2012
roidrage
2
270
A Riak Query Tale
roidrage
5
970
Don't Use NoSQL
roidrage
10
1k
Designing Applications for Amazon Web Services (GOTO Aarhus)
roidrage
6
310
Other Decks in Technology
See All in Technology
キャリアを充実させる『カギ』に!PR TIMES CTO金子達哉から学ぶアウトプット術 / output_method
catatsuy
0
200
LINEにおけるネットワーク自動化チーム / Network Automation Team in LINE
line_developers
PRO
0
130
エンジニアリングマネージャー業の抽象度マッピング / Abstraction mapping of engineering manager's job
yoshikiiida
13
7.5k
1日5分!子育て中もインプットを続ける工夫
morihirok
1
350
データサイエンティストとしてどう学んでいくべきか/東京大学講義: データマイニング概論: #10
yp_genzitsu
10
5.8k
TypeScriptは10年でこんなに進化しました / TechFeed Experts Night 11
okunokentaro
5
1.1k
Amazon Forecast を使って売上予測をしてみた
tomuro
0
290
プログラミング支援AI GitHub Copilot すごいの話
moyashi
0
260
Hasuraの本番運用に向けて
nori3tsu
0
250
Lyssa Adkins : Agilists Superpower and Challenge
kawaguti
PRO
1
150
本社オフィスを移転し、 オフィスファシリティ・コーポレートIT を刷新した話
rotomx
3
1.1k
CEXやDEXに依存しないブロックチェーン取引について考える
sbtechnight
0
310
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1351
200k
Reflections from 52 weeks, 52 projects
jeffersonlam
338
18k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
7
560
The Art of Programming - Codeland 2020
erikaheidi
35
11k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.5k
Pencils Down: Stop Designing & Start Developing
hursman
114
10k
WebSockets: Embracing the real-time Web
robhawkes
58
6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
643
54k
Building Adaptive Systems
keathley
27
1.3k
Infographics Made Easy
chrislema
235
17k
Optimizing for Happiness
mojombo
365
64k
Raft: Consensus for Rubyists
vanstee
130
5.7k
Transcript
cooking infrastructure with chef ruby for scotland 2013, mathias meyer,
@roidrage
travis-ci.org
None
in the beginning...
manual steps
useradd -h /var/www deploy
apt-get install nginx vi /etc/nginx/nginx.conf mkdir /var/www/travis-ci.org cp ~/ssl.cert /etc/nginx/
service nginx reload
apt-get install mysql-server vi /etc/mysql/my.cnf service mysql-server restart mkdir /var/www/travis-ci.org/shared
vi /var/www/travis-ci.org/shared/database.yml
cp /tmp/id_rsa ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa git clone
[email protected]
:travis-ci/travis-ci.git
artisanal shell scripts
every installation howto ever
None
infrastructure grows
infrastructure changes
teams grow and change
automation
chef
None
chef lingo
bork nodes attributes resources providers recipes cookbooks
nodes
attributes
default[:nginx][:version] = '1.1.19-1' default[:users] = [{ id: 1001, username: 'deploy',
home: '/var/www', shell: '/bin/zsh' }]
resources
package "nginx" do version "1.1.19-1" action :install end
package "nginx" do version node[:nginx][:version] action :install end
user 'deploy' do id 1001 shell '/bin/zsh' home '/var/www' end
default[:users] = [{ id: 1001, username: 'deploy', home: '/var/www', shell:
'/bin/zsh' }]
node[:users].each do |user| user user[:login] do uid user[:id] shell user[:shell]
home user[:home] end end
it's all ruby
providers
directories
directory node[:nginx][:www_root] do action :create recursive true end
configuration files
template "/etc/nginx/sites-available/travis-ci.org" do source "travis-ci.org.erb" owner "www-data" group "www-data" mode
"0644" end
template "/etc/nginx/sites-available/travis-ci.org" do source "travis-ci.org.erb" owner "www-data" group "www-data" mode
"0644" end
default[:nginx][:sites_available] = '/etc/nginx/sites-available' default[:nginx][:sites_enabled] = '/etc/nginx/sites-enabled' default[:nginx][:site_config] = "#{node[:nginx][:sites_available]}/" +
"#{node[:nginx][:host_name]}"
template node[:nginx][:site_config] do source "travis-ci.org.erb" owner "www-data" group "www-data" mode
"0644" end
services
service "nginx" do supports reload: true, restart: true action :start
end
template node[:nginx][:site_config] do source "travis-ci.org.erb" owner "www-data" group "www-data" mode
"0644" notifies :reload, 'service[nginx]' end
customizing templates
server { listen 80; server_name <%= @host_name %>; root <%=
@www_root %>; location / { index index.html } }
template "/etc/nginx/sites-available/travis-ci.org" do source "travis-ci.org.erb" notifies :reload, 'service[nginx]' variables www_root:
node[:nginx][:www_root], host_name: node[:nginx][:host_name] end
default[:nginx][:www_root] = '/var/www/travis-ci.org' default[:nginx][:host_name] = 'travis-ci.org'
link "#{node[:nginx][:sites_enabled]}/" + node[:nginx][:host_name] do to node[:nginx][:sites_config] owner "www-data" group
"www-data" end
recipes
package "nginx" do ... end template "/etc/nginx/sites-available/travis-ci.org" do ... end
service "nginx" do ... end
cookbooks
None
simplest chef that could possibly work
chef mantras
order of execution
idempodence
chef is hard
infrastructure is hard
infrastructure automation
big upfront effort
plan to throw 1000 servers away
quantifyable benefits?
how is this better than shell scripts?
common language for infrastructure automation
mttns* mean time to new server
mttr
orchestration
chef solo
opsworks
chef server
chef server stores cookbooks environments nodes data roles
roles www rails mysql-master mysql-slave
environments staging production testing
automate your servers
automate your laptop
learnchef.com
None
github.com/roidrage/scotrubyconf2013