LoginSignup
14
14

More than 5 years have passed since last update.

WindowsでVagrant+Chefする

Last updated at Posted at 2014-03-31

2014年3月19日、Vagrantは1.5.1の時点の話です。

まとめ

knife soloを使うハックが何種類かある。

/etc/fstab
c:      /cygdrive/c

knife-soloのlib/chef/knife/solo_cook.rb:163でcygdriveとかベタ書きなんだけどもうちょっと何とかならんのこれ。

  • もしくはrsyncだけCygwin用のを使う。
  • もしくはVagrantfile中に記述してvagrant provisionで行う。VagrantじゃなくてChefしたい時とか再利用できないしなー。
  • vagrant-berkshelfプラグインはもう古いらしい。入れない。
  • VagrantとかBerkshelfとかChefのスケルトンは、とりあえず最低限で作っていったほうが理解が早い。
  • なんか遅くない?

最低限

  • vagrant plugin install vagrant-omnibus
  • vagrant plugin install vagrant-proxyconf
  • (私の環境では必要なので。)
  • 最低限のVagrantfileでいい。
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  config.vm.hostname = "xxx-berkshelf"

  config.vm.box = "cent6.4"

  config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box"

  config.vm.network :private_network, ip: "33.33.33.10"
  config.proxy.http     = ENV['http_proxy']
  config.proxy.https    = ENV['https_proxy']
  config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
  config.yum_proxy.http     = ENV['http_proxy']

  config.omnibus.chef_version = :latest
end
  • 最低限のBerksfileを作る
Berksfile
site :opscode

cookbook 'yum'
cookbook 'yum-epel'
cookbook 'mysql'
cookbook 'cookbook-yumfastestmirror', git: 'https://github.com/DQNEO/cookbook-yumfastestmirror.git'
cookbook 'chef-yumrepo', git: 'https://github.com/priestjim/chef-yumrepo.git'
  • vagrant up
  • vagrant ssh-config --host melody >> ~/.ssh/config
  • LANG=C knife solo cook melody
  • LANG=ja_JP.UTF-8だと、berkの結果cookbook以下に変なディレクトリが出来る模様。

  • デフォルトでsite-cookbooks以下は実行してくれるので、cookbookはそっちに追加する。knife cookbook createだとファイルが多いので、最低限っぽいcookbookだとCookbook for 最低限の開発環境構築がわかりやすいかな。

Vagrantにproviderを追加するプラグイン(vagrant-awsとか)を入れて、vagrantのprovisionでやるのもatomicだしいいのかもしれないけど、個人的にはknifeでちまちまやるほうがわかりやすい気がする。

しかし時代はansibleらしいですね。(Vagrant と Ansible で Windows でも快適開発

14
14
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
14
14