LoginSignup
48
49

More than 5 years have passed since last update.

Berkshelf入門

Last updated at Posted at 2013-12-30

Berkshelf ver 3 の入門です。

BerkshelfとVagrantを使って、1行もレシピを書かずにnginxサーバを構築してみましょう。

必要なもの

  • Vagrant (v1.6以上を推奨)
  • VirtualBox
  • vagrant-omnibusプラグイン
  • ChefDK(berksコマンドはこれに含まれています)

各ツールのインストール方法についてはこちらの記事をご覧ください。

簡単!今どきのVagrant+ChefSolo入門(2014年9月版)

ここから下は、各ツールはすでにインストール済みという前提で説明します。

chef-repo(作業用ディレクトリ)を作ります

$ cd /tmp
$ mkdir chef-repo
$ cd chef-repo

Berksfileを作成します。

ver2と書き方が違うのでご注意。

Berksfile
source "https://supermarket.chef.io"

cookbook 'nginx'

Berksfileの内容をもとにcookbookを取得します。

$ berks vendor cookbooks

# これでcookbooksの下にサードパーティcookbookが入ります
$ ls cookbooks
apt/  Berksfile.lock  bluepill/  build-essential/  nginx/  ohai/  rsyslog/  runit/  yum/  yum-epel/

Vagrantfileを作成します

Vagrantfile
Vagrant.configure("2") do |config|
   config.vm.box = "chef/centos-6.6"
   config.omnibus.chef_version = :latest
   config.vm.provision :chef_solo do |chef|
     chef.cookbooks_path = "./cookbooks"
     chef.add_recipe "nginx"
   end
end

vagrant upします

$ vagrant up

これだけで、自分でレシピを一つも書かずにnginxのサーバが構築できます。

48
49
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
48
49