VagrantとかjenkinsとかchefとかでCI環境を構築する
というわけでやっていきますが、現段階では全くできていません笑
書きながら構築していこうと思います。
ちなみに参考はこのスライドシェア!!
3分間 開発環境クッキング 2012.07 #pyfes
Vagrant環境の作成
とりあえず公式を参考に。
Vagrant - Getting Started - SSH
まずはディレクトリの作成
mkdir test_project
cd test_project
次にvagrantをスタート!
vagrant init
vagrantのBOXを指定(ちなみに以前boxを作成していたので手順は省きます)
まずはどんなBOXがあるか確認
vagrant box list
CentOS
がありました。
どうでもいいけどこれセントOS ?それともセントス? メントスみたいになってるけど。
ほんとにどうでもいいっすね。
次にboxの指定
vim Vagrantfile
Vagrant::Config.run do |config| config.vm.box = "CentOS" end
こんな感じで指定。…すごくrubyです…
ここまででとりあえずVagrantは終了
VeeWeeを使う
らしいです。
VeeWeeってなんぞ??
→jedi4ever/veewee · GitHub
ふむふむ、box作成の自動化か…
…なるほどわからん!
とにかくスライドシェアの資料に従っていきます。
git clone https://github.com/jedi4ever/veewee
cd veewee
…変なのでた!!
==================================================================================== = NOTICE = ==================================================================================== = RVM has encountered a new or modified .rvmrc file in the current directory = = This is a shell script and therefore may contain any shell commands. = = = = Examine the contents of this file carefully to be sure the contents are = = safe before trusting it! ( Choose v[iew] below to view the contents ) = ==================================================================================== Do you wish to trust this .rvmrc file? (/Users/nigorinumahiroki/project/test_project/veewee/.rvmrc) y[es], n[o], v[iew], c[ancel]>
しらんけど 「y」で!!
ruby-1.9.2-p320 is not installed. To install do: 'rvm install ruby-1.9.2-p320' Running /usr/local/rvm/hooks/after_cd
なんかrubyのバージョンが違う的な。
しゃあないので合わせることに
rvm install ruby-1.9.2-p320
…大丈夫なのか!?
ここ結構時間かかります。
ちなみにrvmをインストールしてなかったらどうなるのだろうか。
…というわけで結構かかっているので飛ばします。
まぁBOXはもうあるし。
Chefを使う
何はなくともインストール
gem install chef
なんか色々出てきたぜ
... [Version 0.7.8] test suite cleanup (eliminated some race conditions related to queue.message_count) Fetching: net-ssh-gateway-1.1.0.gem (100%) Fetching: net-ssh-multi-1.1.gem (100%) Fetching: highline-1.6.15.gem (100%) Fetching: moneta-0.6.0.gem (100%) Fetching: uuidtools-2.1.3.gem (100%) Fetching: chef-10.16.2.gem (100%) Successfully installed mixlib-config-1.1.2 Successfully installed mixlib-cli-1.2.2 Successfully installed mixlib-log-1.4.1 Successfully installed mixlib-authentication-1.3.0 Successfully installed mixlib-shellout-1.1.0 Successfully installed systemu-2.5.2 Successfully installed yajl-ruby-1.1.0 Successfully insta ...
サクセスフライって出てきてるんだからサクセスしてるのだろう。
ちなみに説明がわかんなくなったので次はこちらの記事を参考に
chef-soloで環境設定 — そこはかとなく書くよん。
それからこの本も参考に
Software Design (ソフトウェア デザイン) 2012年 10月号 [雑誌]
- 出版社/メーカー: 技術評論社
- 発売日: 2012/09/18
- メディア: 雑誌
- 購入: 2人 クリック: 26回
- この商品を含むブログ (10件) を見る
こういうの買っといてよかったと毎回思う。
約10分後完了!!
git clone git://github.com/opscode/chef-repo.git
予めテンプレがあるみたいなので拝借
現在のファイル構成はこんな感じ
test_project/ - Vagrantfile/ - chef-repo/ - veewee/
次はcookbookの中身を作る。
cookbook
chef-repoディレクトリに移動
そして
rake new_cookbook COOKBOOK=test_book
と入力
すると
chef-repo/ - cookbooks/ -- test_books/
てなわけでtest_booksというディレクトリが出来上がりました。
それからknifeコマンドでも色々出来るらしい
knife cookbook site install ntp -o cookbooks
スライドシェアにのってた。
Vagrantfileを書きなおす
というわけで一旦test_projectディレクトリに戻る。
Vagrantfileを書きなおします
Vagrant::Config.run do |config| config.vm.box = "CentOS" config.vm.customize do |vm| vm.memory_size = 512 end config.vm.provision :chef_solo do |chef| chef.cookbooks_path = ["cookbooks"] chef.add_recipe "ntp" chef.json = { :ntp => { :servers => ['ntp.foobar.jp']}, } end end
そしてvagrantを起動!
vagrant up
。。。
Could not locate Gemfile
。。。
何これワロタwww
。。。
確認
gem -v
1.8.24
あるよね。。。
試しに他のディレクトリで
vagrant init
としたら
Could not locate Gemfile
ワロタwwwワロタ…
というわけでsolo-solo体力の限界なので志半ばですがやめます。
まずはvagrant コマンドの復帰から!
では