environment
- Chef Development Kit: 3.8.14
- chef-client version: 14.10.9
- berks version: 7.0.7
- kitchen version: 1.24.0
- inspec version: 3.6.6
background
chefを利用するのに bundle install
して利用していたが、依存関係で嵌ると沼から抜け出せない事が多かった。
例えば、 Gemfile
で利用したいgemをバージョン固定して、 bundle install
。
bundle install Fetching gem metadata from https://rubygems.org/....... Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Bundler could not find compatible versions for gem "chef-zero": In Gemfile: chef-zero (= 13.0) chef (= 14.7.17) was resolved to 14.7.17, which depends on chef-zero (>= 13.0) Bundler could not find compatible versions for gem "mixlib-log": In Gemfile: chef (= 14.7.17) was resolved to 14.7.17, which depends on mixlib-log (>= 2.0.3, ~> 2.0) chef-zero (= 13.0) was resolved to 13.0.0, which depends on mixlib-log (~> 1.3) Bundler could not find compatible versions for gem "net-ssh": In Gemfile: chef (= 14.7.17) was resolved to 14.7.17, which depends on net-ssh (~> 4.2) chef (= 14.7.17) was resolved to 14.7.17, which depends on net-sftp (>= 2.1.2, ~> 2.1) was resolved to 2.1.2, which depends on net-ssh (>= 2.6.5) chef (= 14.7.17) was resolved to 14.7.17, which depends on serverspec (~> 2.7) was resolved to 2.41.3, which depends on specinfra (~> 2.72) was resolved to 2.76.9, which depends on net-ssh (>= 2.7)
Resolving dependencies...
なので、依存関係のgemもバージョン指定しつつ Gemfile
へ追加。再度 bundle install
。。。出力されたエラー内容は変わらない。少しずつマイナーバージョンを下げつつ試行錯誤。これは時間が勿体無さすぎる。。
alias張れば良いが、毎回 bundle exec knife
とかやるのも何とかしたい。
chefDK
about chefDK
- chef-client、Ruby、RubyGems、OpenSSL、Test Kitchen等各種ツールが含まれたDevelopment Kit。
- 公式に利用が推奨されている(gem installよりも)。
/opt/chefdk
C:/opscode/chefdk
等特定ディレクトリに配置し、chefDKのコンポーネントが他アプリケーションへ干渉しないようにする。- gem依存関係が衝突する可能性を減らす。
尚、現時点では 3.8.14
を利用している。
install
https://downloads.chef.io/chefdk
私は MacOS 10.14
のinstallerをdownload。
chef -v Chef Development Kit Version: 3.8.14 chef-client version: 14.10.9 berks version: 7.0.7 kitchen version: 1.24.0 inspec version: 3.6.6
set PATH
私は ~/.zshrc
にてknifeにalias張ってた為、コメントアウトしてPATH追加。
#alias knife="bundle exec knife" export PATH=/opt/chefdk/embedded/bin:$PATH
exec zsh which gem /opt/chefdk/embedded/bin/gem which knife /opt/chefdk/embedded/bin/knife
問題なくknifeも動く。
knife node list knife bootstrap windows winrm --bootstrap-version 14.10.9 x.x.x.x -x xxx_user --secret-file ~/.chef/data_bag_key -E dev -P xxx -N xxx Doing old-style registration with the validation key at ~/.chef/chef-validator.pem...
bootstrapも問題無い。
PS C:\Users\xxx> chef-client Starting Chef Client, version 14.10.9 INFO: *** Chef 14.10.9 *** INFO: Platform: x64-mingw32 INFO: Chef-client pid: 3660 INFO: The plugin path C:\chef\ohai\plugins does not exist. Skipping... INFO: Run List is [] INFO: Run List expands to [] INFO: Starting Chef Run for xxx INFO: Running start handlers INFO: Start handlers complete. INFO: Error while reporting run start to Data Collector. URL: https://xxx/data-colle ctor Exception: 404 -- 404 "Object Not Found" (This is normal if you do not have Chef Automate) resolving cookbooks for run list: [] INFO: Loading cookbooks [] Synchronizing Cookbooks: Installing Cookbook Gems: Compiling Cookbooks... WARN: Node xxx has an empty run list. Converging 0 resources INFO: Chef Run complete in 0.453025 seconds Running handlers: INFO: Running report handlers Running handlers complete INFO: Report handlers complete Chef Client finished, 0/0 resources updated in 07 second
note.
chefDKは各versionが固定されている為、異なるversionを利用したい場合はchefDK利用せずGemfileに書いて bundle install
するしか無さそう。