3
4

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実践入門 実機にて実施メモ(3) vagrantでChefSoloを利用する設定

Last updated at Posted at 2015-06-10

Chef実践入門 第5章のvagrantによるクックブック開発環境の構築 を実機にて検証したメモ
ローカルからknife-solo コマンドを使ってクックブックを適用するのではなく、Vagrantでプロビジョニングする時に自動でクックブックを適用する設定。

#0.環境前提
MacOSX , vagrant ,virtualboxインストール済み

#1.vagrantでChefSoloを使う設定を行う

##1.vagrant-omnibus のインストール

vagrant plugin install vagrant-omnibus
vagrant plugin list

##2.Vagrantfileを以下に設定

Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos6.5"
config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5-i386_chef-provisionerless.box"

config.vm.network "private_network", ip: "192.168.33.10"

# vagrant-omnibusの有効化
config.omnibus.chef_version = :latest

# Chef solo の設定
  config.vm.provision :chef_solo do |chef|
    # クックブックの配置場所
    chef.cookbooks_path = "./chef/cookbooks"
    # Attributeの定義
    chef.json = {
      nginx: {
        env: "ruby"
        },
        fluented: {
          installer: "rpm"
        },
        mysql: {
          server_root_password: 'rootpass'
        }
    }
    #適用するクックブックの定義 (まだクックブックがないので一旦コメントアウト)
    #chef.run_list = %w[
      #recipe[yum-epel]
      #recipe[nginx]
      #recipe[mysql]
      #recipe[fluented]
    #]
  end
end

#2.Vagrant起動時にプロビジョニングを実施

vagrant up --provision

*起動後にプロビジョニングを実行する場合は以下コマンド

vagrant provision
3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?