LoginSignup
3
2

More than 5 years have passed since last update.

パーフェクトRuby on Rails 8章でChefとBerkshelfを使ったgitのインストールの際vagrant provisionが失敗する

Last updated at Posted at 2016-06-26

パーフェクト Ruby on Railsを使って勉強しています。

8章の「ChefのレシピをVagrant上のVMに適用する」というところで、vagrant provisionが詰まりました。
環境と実際に打ったコマンド、その結果が以下になります。

Name Version
Ruby 2.1.2
Vagrant 1.8.1
Chef 11.12.4
Berkshelf 3.1.2
$ vagrant reload && vagrant provision                                                                                                                                                           ⏎
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Auto-generating node name for Chef...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 80 (guest) => 8080 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
[default] GuestAdditions 5.0.22 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /Users/keisei/Vagrant/rails
    default: /tmp/vagrant-chef/063272335eb6c72094819d965105d9d2/cookbooks => /Users/keisei/Vagrant/rails/cookbooks
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
==> default: Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2016-06-26T12:38:48+00:00] INFO: Forking chef instance to converge...
==> default: [2016-06-26T12:38:48+00:00] WARN:
==> default: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
==> default: SSL validation of HTTPS requests is disabled. HTTPS connections are still
==> default: encrypted, but chef is not able to detect forged replies or man in the middle
==> default: attacks.
==> default:
==> default: To fix this issue add an entry like this to your configuration file:
==> default:
==> default: ```
==> default:   # Verify all HTTPS connections (recommended)
==> default:   ssl_verify_mode :verify_peer
==> default:
==> default:   # OR, Verify only connections to chef-server
==> default:   verify_api_cert true
==> default: ```
==> default:
==> default: To check your SSL configuration, or troubleshoot errors, you can use the
==> default: `knife ssl check` command like so:
==> default:
==> default: ```
==> default:   knife ssl check -c /tmp/vagrant-chef/solo.rb
==> default: ```
==> default:
==> default: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
==> default: Starting Chef Client, version 11.12.2
==> default: [2016-06-26T12:38:49+00:00] INFO: *** Chef 11.12.2 ***
==> default: [2016-06-26T12:38:49+00:00] INFO: Chef-client pid: 1325
==> default: [2016-06-26T12:38:52+00:00] INFO: Setting the run_list to ["recipe[git]"] from CLI options
==> default: [2016-06-26T12:38:52+00:00] INFO: Run List is [recipe[git]]
==> default: [2016-06-26T12:38:52+00:00] INFO: Run List expands to [git]
==> default: [2016-06-26T12:38:52+00:00] INFO: Starting Chef Run for vagrant-db7d5867
==> default: [2016-06-26T12:38:52+00:00] INFO: Running start handlers
==> default: [2016-06-26T12:38:52+00:00] INFO: Start handlers complete.
==> default: Compiling Cookbooks...
==> default:
==> default: ================================================================================
==> default: Recipe Compile Error in /tmp/vagrant-chef/063272335eb6c72094819d965105d9d2/cookbooks/compat_resource/libraries/autoload.rb
==> default: ================================================================================
==> default:
==> default:
==> default: RuntimeError
==> default: ------------
==> default: This resource is written with Chef 12.5 custom resources, and requires at least Chef 12.0 used with the compat_resource cookbook, it will not work with Chef 11.x clients, and those users must pin their cookbooks to older versions or upgrade.
==> default:
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default:   /tmp/vagrant-chef/063272335eb6c72094819d965105d9d2/cookbooks/compat_resource/libraries/autoload.rb:2:in `<top (required)>'
==> default:
==> default:
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef/063272335eb6c72094819d965105d9d2/cookbooks/compat_resource/libraries/autoload.rb:
==> default:
==> default:   1:  unless Gem::Requirement.new(">= 12.0").satisfied_by?(Gem::Version.new(Chef::VERSION))
==> default:   2>>   raise "This resource is written with Chef 12.5 custom resources, and requires at least Chef 12.0 used with the compat_resource cookbook, it will not work with Chef 11.x clients, and those users must pin their cookbooks to older versions or upgrade."
==> default:   3:  end
==> default:   4:
==> default:   5:  # If the gem is already activated rather than the cookbook, then we fail if our version is DIFFERENT.
==> default:   6:  # The user said they wanted this cookbook version, they need to have this cookbook version.
==> default:   7:  # NOTE: if the gem is installed but on a different version, we simply don't care: the cookbook version wins.
==> default:   8:  #       If another gem depends on a different version being there, rubygems will correctly throw the error.
==> default:   9:  if Gem.loaded_specs["compat_resource"]
==> default:  10:    # Read our current version
==> default:  11:    version_rb = IO.read(File.expand_path("../../files/lib/compat_resource/version.rb", __FILE__))
==> default:
==> default:
==> default:
==> default:
==> default: Running handlers:
==> default: [2016-06-26T12:38:52+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default:
==> default: [2016-06-26T12:38:52+00:00] ERROR: Exception handlers complete
==> default: [2016-06-26T12:38:52+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: Chef Client failed. 0 resources updated in 3.574904477 seconds
==> default: [2016-06-26T12:38:52+00:00] ERROR: This resource is written with Chef 12.5 custom resources, and requires at least Chef 12.0 used with the compat_resource cookbook, it will not work with Chef 11.x clients, and those users must pin their cookbooks to older versions or upgrade.
==> default: [2016-06-26T12:38:52+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

これはVagrant側のchef-clientのバージョンが古いことによって起こります。
そこで、以下を実行します。

(ホストPC側で)
$ vagrant ssh
(ゲストPCの中で)
$ curl -L https://www.opscode.com/chef/install.sh | sudo bash -s -- -v 12.10.24
$ exit
(ホストPC側で)
$ vagrant provision
3
2
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
3
2