概要
Windows7環境にChef-solo、Knifesolo、VirtualBox、VagrantをインストールしてChefを試してみる
なんとなく動くけど、動かないことも多々ある。MacかLinux使ったほうがbetter
※書きながら気づいたけど、Chef Clientのmsi使えばいいんじゃん。。。。orz
メモ
・Chef-Repoを決めておく c:\var\opt\chef\repos
・Chef-RepoにVagrantfileを配置する
・hosts(DNS)とssh/configをうまく利用する(Vagrantやsshするとき便利)
作業の流れ
Ruby/bundlerインストール
↓
ssh/rsyncインストール
↓
Chef/Knife-Soloインストール
↓
VirtualBoxインストール
↓
Vagrantインストール
Ruby/Bundlerインストール
-
RubyInstaller for Windows より最新版のRubyをダウンロードし、インストールする
Version:1.9.3-p550
PATH:C:\var\opt\ruby193
※Development KITもインストールしておく
> ruby dk.rb init > ruby dk.rb install
-
インストール後、コマンドプロンプトから以下を実行・確認
>ruby -v ruby 1.9.3p550 (2014-10-27) [i386-mingw32]
-
Bundlerをインストール
>gem install bundler
-
不要パッケージ削除
>gem uninstall win32-api >gem uninstall chef >gem uninstall knife-solo
-
tmpディレクトリを作成し、Gemfileを作成
>mkdir c:\tmp >dir Gemfile >type Gemfile source 'https://rubygems.org' gem "knife-solo" gem "win32-api", "~> 1.5.1", platforms: [:mingw, :x64_min # for chef-solo on Windows #gem "ruby-wmi", platforms: [:mingw, :x64_mingw] #gem "win32-service", platforms: [:mingw, :x64_mingw]
-
bundle install実施
>bundle install Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... Installing erubis 2.7.0 Installing highline 1.6.21 Gem::InstallError: The 'json' native gem requires installed build tools. Please update your PATH to include build tools or download the DevKit from 'http://rubyinstaller.org/downloads' and follow the instructions at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit' An error occurred while installing json (1.7.7), and Bundler cannot cont Make sure that gem install json -v '1.7.7' succeeds before bundling.
sshとrsyncをインストール
-
MinGW - Minimalist GNU for Windowsからmingwをダウンロードし、インストール
Version:0.6.2
PATH:c:\var\opt/MinGW
※mysys-openssh (bin)とmsys-rsync (bin)をインストール
※~/.ssh/configを作成しておくと便利
>type ~/.ssh/config Host 127.0.0.1 HostName 127.0.0.1 Port 2222 IdentityFile C:\Users\user.vagrant.d\insecure_private_key User vagrant
C:\var\opt\MinGW\binとC:\var\opt\MinGW\msys\1.0\binにPATHを通す
C:\var\opt\MinGW\msys\1.0\etc\fstab を以下のように記載
C: /cygdrive/c
C:/home /home
Chef/Knife-Soloインストール
-
Chefをインストール
>gem install chef Fetching: libyajl2-1.2.0.gem (100%) Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... Successfully installed libyajl2-1.2.0 1 gem installed Installing ri documentation for libyajl2-1.2.0... Installing RDoc documentation for libyajl2-1.2.0...
-
Knife-Soloをインストール
>gem install knife-solo
-
Chef Deployment Kitをインストール
>berks version 3.2.1
VartualBoxをインストール
- VirtualBoxより最新版のVirtualBoxをダウンロードし、インストールする Version:4.3.18 PATH:C:\var\opt\VirtualBox
Vagrantをインストール
VagrantbよりVagrantをダウンロードし、インストールする
Version:1.6.5
PATH:C:\var\opt\Vagrant-
コマンドプロンプトよりバージョン確認
>vagrant -v Vagrant 1.6.5