10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ChefとVagrantで楽しいクッキング

Last updated at Posted at 2014-01-14

素材

Vagrant: 開発環境を簡単に構築・管理し、配布することができる開発環境作成ツール
Virtual Box: 仮想化ソフトウェア、Vagrantのプロバイダとして使用
Chef: 設定ファイルCookbookに従って、自動的にユーザやパッケージの追加を行うサーバー設定管理ツール
berkshelf: アプリケーションの依存関係とCookbookの管理をしてくれる

0. ホストマシン前提環境

Ruby 1.9以降

1. Vagrantインストール

http://www.vagrantup.com/downloads.html よりホストマシンOSのパッケージを
ダウンロードしてインストール、バージョンが表示されればOK

$ vagrant -v
Vagrant 1.4.1

2. Virtual Boxインストール

https://www.virtualbox.org/wiki/Downloads よりホストマシンOSのパッケージを
ダウンロードしてインストール
Vagrant が求めるVirtual Box のバージョンは、4.0.x 4.1.x 4.2.x 4.3.x.

3. VagrantからVMを起動準備

ChefプリインストールのCentOS6.3のBoxを設定

$ mkdir vagrant-centos
$ cd vagrant-centos
$ vagrant init centos-chef https://s3.amazonaws.com/itmat-public/centos-6.3-chef-10.14.2.box

4. BerkshelfでCookbook管理

Berkshelfをインストールし、設定Berskfileを編集

$ vagrant plugin install vagrant-berkshelf
$ gem install berkshelf
$ vi Berksfile
Berksfile
site :opscode

cookbook 'nginx'
$ berks install --path=vendor/cookbooks

5. Vagrantでレシピを追加してプロビジョニングから起動まで

Vagrantfileにレシピを追加します。

Vagrantfile
......
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  ......
  ......
  config.berkshelf.enabled = true
  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "./vendor/cookbooks"
    chef.add_recipe "nginx"
  end
end
......

あとは3分ほど待つだけ!

$ vagrant up
10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?