7
8

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.

Windows de Vagrant + ChefDK

Posted at

前提条件

  • Windows7 Service Pack 1
  • Virtualbox 4.3.16
  • Vagrant 1.6.5
  • ChefDK 0.3.0

インストール

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

c:\opscode\chefdk\bin\chef gem install knife-solo

Vagrantfile作成

  • Vagrantfileを新規作成し、編集する。
  • Boxファイルはvagrant cloudのchef/centos-6.5を使用する。

vagrant login
vagrant init chef/centos-6.5
Vagrantfile
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "chef_solo" do |chef|
  chef.cookbooks_path = ["./chef-repo/site-cookbooks", "./chef-repo/cookbooks"]
  chef.roles_path = "./chef-repo/roles"
  chef.add_role "local"
  end

Vagrant起動


vagrant up

GuestOSへSSH


Host:127.0.0.1
Port:2222
User:vagrant
Key:~/.vagrant.d\insecure_private_key

GuestOSにCHefDKインストール


$ sudo rpm -ivh https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chefdk-0.3.0-1.x86_64.rpm

Chefリポジトリ作成


c:\opscode\chefdk\bin\knife solo init chef-repo

Chef Cookbook作成


cd chef-repo
c:\opscode\chefdk\bin\knife solo create httpd -o sitecookbooks
roles/local.json
{
  "name": "local",
  "default_attributes": { },
  "override_attributes": { },
  "json_class": "Chef::Role",
  "description": "local",
  "chef_type": "role",
  "run_list": [
    "recipe[httpd]"
  ]
}

Apache Recipe作成

site-cookbooks\httpd\recipes
package "httpd" do
  action :install
end

service "httpd" do
  supports :status => true,:restart => true,:reload => true
  action [:enable,:start]
end

プロビジョニング


vagrant provision
7
8
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
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?