3
votes

Alright so I am using a bunch of technologies that are new to me here, so I'm not sure how to slice up the problem. I have a little experience with vagrant, and am trying to learn Chef now.

I've cloned this cookbook: https://github.com/opscode-cookbooks/mysql to my ./cookbooks/mysql directory. I'm trying to run that cookbook via Vagrant with this Vagrantfile:

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

# Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
Vagrant::Config.run do |config|

    config.vm.box = "precise64"
    config.vm.box_url = "http://files.vagrantup.com/precise64.box"


    config.vm.define "mysql" do |mysql|

        mysql.vm.network :hostonly, "192.168.33.12"

        mysql.vm.provision :chef_solo do |chef|
            chef.cookbooks_path = "cookbooks"
            chef.add_recipe "mysql"

            chef.json = {
                :server => {
                    version: '5.6',
                    port: '3307',
                    data_dar: '/data-mysql',
                    allow_remote_root: true,
                    remove_anonymous_Users: true,
                    remove_test_database: true
                }
            }
        end
    end
end

When I run 'vagrant up mysql' I get this output:

Running chef-solo...
stdin: is not a tty
[2014-05-07T17:20:23+00:00] INFO: *** Chef 10.14.2 ***
[2014-05-07T17:20:23+00:00] INFO: Run List is []
[2014-05-07T17:20:23+00:00] INFO: Run List expands to []
[2014-05-07T17:20:23+00:00] INFO: Starting Chef Run for precise64
[2014-05-07T17:20:23+00:00] INFO: Running start handlers
[2014-05-07T17:20:23+00:00] INFO: Start handlers complete.

================================================================================
Recipe Compile Error in /tmp/vagrant-chef-2/chef-solo-1/cookbooks/mysql/libraries/provider_mysql_service_omnios.rb
================================================================================

LoadError
---------
no such file to load -- chef/provider/lwrp_base

Cookbook Trace:
---------------
  /tmp/vagrant-chef-2/chef-solo-1/cookbooks/mysql/libraries/provider_mysql_service_omnios.rb:1

Why is this failing? I wonder if the mysql cookbook has a dependency on another cookbook that should provide the 'chef/provider/lwrp_base' file.

UPDATE: The issue could be that Vagrant is running Chef 10.14.2, and the cookbook is marked as requiring Chef 11 here (http://community.opscode.com/cookbooks/mysql).

There are quite a few files referencing LWRP, shown here:

> gci .\cookbooks * -rec | select-string lwrp

cookbooks\mysql\CHANGELOG.md:320:- [COOK-684] remove mysql_database LWRP
cookbooks\mysql\libraries\provider_mysql_client.rb:5:    class MysqlClient < Chef::Provider::LWRPBase
cookbooks\mysql\libraries\provider_mysql_client_debian.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_client_fedora.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_client_omnios.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_client_rhel.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_client_smartos.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_client_ubuntu.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_service.rb:5:    class MysqlService < Chef::Provider::LWRPBase
cookbooks\mysql\libraries\provider_mysql_service_debian.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_service_fedora.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_service_omnios.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_service_rhel.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_service_smartos.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\provider_mysql_service_ubuntu.rb:1:require 'chef/provider/lwrp_base'
cookbooks\mysql\libraries\resource_mysql_client.rb:1:require 'chef/resource/lwrp_base'
cookbooks\mysql\libraries\resource_mysql_client.rb:5:    class MysqlClient < Chef::Resource::LWRPBase
cookbooks\mysql\libraries\resource_mysql_service.rb:1:require 'chef/resource/lwrp_base'
3

3 Answers

4
votes

You can overcome this using the vagrant omnibus plugin

Just run 'vagrant plugin install vagrant-omnibus' to add it, and add 'config.omnibus.chef_version = :latest' to the top of your vagrantfile, like so

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

  config.omnibus.chef_version = :latest

  ...

end
0
votes

In the directory above your cookbooks, this may show what is referencing lwrp:

find cookbooks -exec grep lwrp {} \; -print

0
votes

Ok, the problem was that my vagrant box had an older version of Ruby and Chef installed. It all works now, the source is at https://github.com/fschwiet/helloVagrant/tree/ceafdc9916e788136ae79f20722e77d76e2f1eef