Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vagrant+Chef Hands-on
Search
Kenichi Takahashi
May 27, 2013
Technology
0
320
Vagrant+Chef Hands-on
2013/05/23に開催した60min.での資料です。
Kenichi Takahashi
May 27, 2013
Tweet
Share
More Decks by Kenichi Takahashi
See All by Kenichi Takahashi
実践、マルチクラウド環境でのコスト管理の現状と未来
kenchan
0
150
エンジニアリング 💰Moneyジャー / Engineering Money-ger
kenchan
2
850
Lv1,2の開発生産性を経営と繋ぐ
kenchan
4
2.1k
「トップ10プランナー」からはじめる目標設定
kenchan
5
4.2k
負債と言わないことが負債と向き合うこと
kenchan
5
4.5k
可用性No.1へ!「カラーミーショップ」のリ・アーキテクティング
kenchan
0
170
カラーミーショップは私たちが作っています
kenchan
0
1.7k
カラーミーショップ 2022 / COLORME SHOP 2022
kenchan
0
720
Amazon RDS移行のための 性能検証でわかった2つのこと
kenchan
3
4.2k
Other Decks in Technology
See All in Technology
15 years with Rails and DDD (AI Edition)
andrzejkrzywda
0
190
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
470
Agile Leadership Summit Keynote 2026
m_seki
1
620
Webhook best practices for rock solid and resilient deployments
glaforge
1
290
Amazon S3 Vectorsを使って資格勉強用AIエージェントを構築してみた
usanchuu
3
450
ClickHouseはどのように大規模データを活用したAIエージェントを全社展開しているのか
mikimatsumoto
0
230
AI駆動開発を事業のコアに置く
tasukuonizawa
1
200
変化するコーディングエージェントとの現実的な付き合い方 〜Cursor安定択説と、ツールに依存しない「資産」〜
empitsu
4
1.4k
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.5k
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
170
AI駆動PjMの理想像 と現在地 -実践例を添えて-
masahiro_okamura
1
110
Context Engineeringが企業で不可欠になる理由
hirosatogamo
PRO
3
590
Featured
See All Featured
Bash Introduction
62gerente
615
210k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
57
50k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
78
Building an army of robots
kneath
306
46k
A better future with KSS
kneath
240
18k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Building the Perfect Custom Keyboard
takai
2
680
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
How STYLIGHT went responsive
nonsquared
100
6k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
37k
Transcript
Vagrant & Chef ハンズオン @kenchan
今日のゴール Vagranの使い方がなんとなくわかる knifesoloの使い方がなんとなくわかる おまけで screen と apache がインストールされたCentOSの VMをお持ち替えりいただけます。
事前の準備
各種インストール VirtualBox のインストール Vagrant のインストール
BaseBox の登録 $ vagrant box add opscode-centos-64 \ https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_chef-11.4.4.box $
vagrant box list opscode-centos-64 (virtualbox)
ハンズオン開始
vagrant init $ mkdir vagrant-handson $ cd vagrant-handson $ vagrant
init opscode-centos-64 Vagrantfile というものができていますね。
Vagrantfileを見てみよう config.vm.box config.vm.box_url vm.box はBase Boxの名前、 vm.box_url は Base Box
がな いときのダウンロードURL。名前の衝突は注意。
VMの作成と起動 vagrant up VirtualBoxの画面を開いておくと、VMができあがって起動する 様子を確認できます。
SSHで繋いでみよう vagrant ssh ユーザはvagrant。パスワード無しで sudo できる。
普通にSSHしてみよう $ vagrant ssh-config --host melody $ vagrant ssh-config --host
melody >> ~/.ssh/config $ ssh melody
knifesolo のインストール Gemfileを書いて bundle install しましょう。 source 'https://rubygems.org' gem 'knife-solo',
'~> 0.3.0.pre3'
knifesoloのセットアップ(1) $ bundle exec knife configure $ bundle exec knife
solo init . $ bundle exec knife solo prepare melody configureはchefの設定します。(今回は不要かも?) initはcookbookなどを置くディレクトリの作成します。
knifesoloのセットアップ(2) prepareは、以下の2ステップを行うので、chefが入っている VMで、nodesのjsonを自分で書けば不要です。 nods/melody.json を作る sshでVMに入り chef をインストールする
knifeを実行してみよう $ bundle exec knife solo cook melody エラーが出ないこと確認しましょう。
VMにscreenをインストール $ bundle exec knife cookbook create screen -o site-cookbooks
sitecookbooksに入れるべきかは議論の余地がありますが、今 回はsitecookbooksとします。
レシピの書き方 sitecookbooks/screen/recipes/default.rb package 'screen' do action :install end ふつうにRubyが書けますよ。
melodyにscreenを入れる nodes/melody.json { "run_list": [ "screen" ] } インストールしてみよう $
bundle exec knife solo cook melody
動作確認 $ vagrant ssh $ screen screenの中でscreenにならないように注意してね。
外部のcookbookを使う cookbookの管理ツールはいろいろありますが、今回 は Berkshelf を使ってみましょう。 Gemfileに gem 'berkshelf' を追加し て
bundle install します。
apache2のcookbookを利用 Berksfile site :opscode cookbook 'apache2' install $ bundle exec
berks install -p cookbooks
困っていること(1) berks install だけだ と、 ~/.berksfile/cookbooks に入ってしま い、 .chef/knife.rb のcookbookにpathを入れても見つけ
てくれない…
困っていること(2) berks install -p すると、ディレクトリ空っぽにしてか らインスールするので、実は vendor/cookbook とかにした ほうがいい? (たとえば自作のscreenのcookbook
を cookbooks に入れるとここで消されてしまう)
apache2をインストール nodes/melody.json { "run_list": [ "screen", "apache2" ] } $
bundle exec knife solo cook melody
起動しているか確認 $ vagrant ssh $ curl localhost > 404 Not
Found!!!
ホストからアクセス(1) VMを停止します。 $ vagrant halt Vagrantfileでコメントアウトされている箇所を戻します。 config.vm.network :private_network, ip: "192.168.33.10"
ホストからアクセス(2) $ vagrant up $ curl http://192.168.33.10/ > 404 Not
Found!!!
おわり なにかご質問は
おまけ VMの消し方 $ vagrant destroy
おまけ バージョン管理について .vagrant は環境依存なのでignoreに。 あとは全部管理した ほうがいいのでは。
おまけ VMのスナップショットでどうするの? VirtualBox上でやってもいいけど、Vagrantのプラグインがある よ。