9
9

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.

Vagrant + Chef + Ruby2.1.0

Last updated at Posted at 2014-08-24

前提条件

  • Mac OS X(10.9.3)
  • Virtualbox 4.3.6
  • Vagrant 1.4.3

インストール

  • 下記のGEMをインストールする。

$ gem install chef
$ gem install knife-solo
$ gem install berkshelf

Vagrantfile作成


$ vagrant init ruby
$ vim Vagrantfile
Vagrantfile
config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box"
config.vm.network :private_network, ip: "192.168.33.10"
config.omnibus.chef_version = :latest
config.vm.provision :chef_solo do |chef|
   chef.cookbooks_path = ["./chef-repo/cookbooks", "./chef-repo/site-cookbooks"]
  chef.roles_path = "./chef-repo/roles"
  chef.add_role "local"
end

Chefリポジトリ作成


$ knife solo init chef-repo

Community Cookbookダウンロード


$ cd chef-repo
$ berks init
$ vim Berksfile
$ berks vendor cookbooks
Berksfile
source "https://supermarket.getchef.com"
cookbook 'ruby_build'
cookbook 'rbenv', github: "fnichol/chef-rbenv"

Chef Cookbook作成


$ vim nodes/local.json
$ vim roles/local.json
nodes/local.json
{
  "run_list": "role[local]"
}
roles/local.json
{
  "name": "local",
  "default_attributes": {
    "rbenv": {
      "rubies": ["2.1.0"],
      "global": "2.1.0",
        "gems": {
          "2.1.0": [
            {"name": "bundler"}
          ]
        }
      }
    },
  "override_attributes": { },
  "json_class": "Chef::Role",
  "description": "local",
  "chef_type": "role",
  "run_list": [
    "recipe[ruby_build]",
    "recipe[rbenv::system]"
  ]
}

Vagrantプラウグインインストール


$ vagrant plugin install vagrant-omnibus

Vagrant起動


$ vagrant up

プロビジョニング


$ vagrant provision
9
9
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
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?