Search code examples
mysqlrubyvagrantchef-infrachef-recipe

Unable to install mysql-client using chef cookbook on a vagrant box


I have been trying to install chef-client using this chef cookbook. When in include recipe mysql::client it tries to install mysql gem client. Throws out lot of error, I am not able to debug the issue. I googled a lot,but nothing turned up. Please let me know the solution, if required I will post the entire stack trace, but its too long.

Also if I remove mysql::client recipe for the cookbook it will install mysql::server and also client with out fail. When I explicitly include mysql::client it tries to install mysql-client gem for some reason.

here is the error log

Error executing action `install` on resource 'chef_gem[mysql]'
==> default: ================================================================================
==> default: 
==> default: 
==> default: 
==> default: Gem::Installer::ExtensionBuildError
==> default: 
==> default: -----------------------------------
==> default: ERROR: Failed to build gem native extension.
==> default: 
==> default:         /opt/chef/embedded/bin/ruby extconf.rb
==> default: checking for mysql_query() in -lmysqlclient... no
==> default: checking for main() in -lm... yes
==> default: checking for mysql_query() in -lmysqlclient... no
==> default: checking for main() in -lz... yes
==> default: checking for mysql_query() in -lmysqlclient... no
==> default: checking for main() in -lsocket... no
==> default: checking for mysql_query() in -lmysqlclient... no
==> default: checking for main() in -lnsl... yes
==> default: checking for mysql_query() in -lmysqlclient... no
==> default: checking for main() in -lmygcc... no
==> default: checking for mysql_query() in -lmysqlclient... no
==> default: *** extconf.rb failed ***
==> default: Could not create Makefile due to some reason, probably lack of
==> default: necessary libraries and/or headers.  Check the mkmf.log file for more
==> default: details.  You may need configuration options.
==> default: 
==> default: Provided configuration options:
==> default:    --with-opt-dir
==> default:    --with-opt-include
==> default:    --without-opt-include=${opt-dir}/include
==> default:    --with-opt-lib
==> default:    --without-opt-lib=${opt-dir}/lib
==> default:    --with-make-prog
==> default:    --without-make-prog
==> default:    --srcdir=.
==> default:    --curdir
==> default:    --ruby=/opt/chef/embedded/bin/ruby
==> default:    --with-mysql-config
==> default:    --without-mysql-config
==> default:    --with-mysql-dir
==> default:    --without-mysql-dir
==> default:    --with-mysql-include
==> default:    --without-mysql-include=${mysql-dir}/include
==> default:    --with-mysql-lib
==> default:    --without-mysql-lib=${mysql-dir}/lib
==> default:    --with-mysqlclientlib
==> default:    --without-mysqlclientlib
==> default:    --with-mlib
==> default:    --without-mlib
==> default:    --with-mysqlclientlib
==> default:    --without-mysqlclientlib
==> default:    --with-zlib
==> default:    --without-zlib
==> default:    --with-mysqlclientlib
==> default:    --without-mysqlclientlib
==> default:    --with-socketlib
==> default:    --without-socketlib
==> default:    --with-mysqlclientlib
==> default:    --without-mysqlclientlib
==> default:    --with-nsllib
==> default:    --without-nsllib
==> default:    --with-mysqlclientlib
==> default:    --without-mysqlclientlib
==> default:    --with-mygcclib
==> default:    --without-mygcclib
==> default:    --with-mysqlclientlib
==> default:    --without-mysqlclientlib
==> default: 
==> default: 
==> default: Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mysql-2.9.1 for inspection.
==> default: Results logged to /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
==> default: 
==> default: 
==> default: 
==> default: Cookbook Trace:
==> default: ---------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/mysql-chef_gem/libraries/provider_mysql_chef_gem.rb:20:in `block in action_install'
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/mysql-chef_gem/libraries/provider_mysql_chef_gem.rb:11:in `action_install'
==> default: 
==> default: 
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef-3/chef-solo-1/cookbooks/mysql-chef_gem/libraries/provider_mysql_chef_gem.rb
==> default: 
==> default:  20:           chef_gem 'mysql' do
==> default:  21:             action :install
==> default:  22:           end
==> default:  23:         end
==> default: 
==> default: 
==> default: 
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/mysql-chef_gem/libraries/provider_mysql_chef_gem.rb:20:in `block in action_install'
==> default: 
==> default: chef_gem("mysql") do
==> default:   provider Chef::Provider::Package::Rubygems
==> default:   action [:install]
==> default:   retries 0
==> default:   retry_delay 2
==> default:   guard_interpreter :default
==> default:   package_name "mysql"
==> default:   version "2.9.1"
==> default:   cookbook_name :"mysql-chef_gem"
==> default: end
==> default: 
==> default: 
==> default: 

Solution

  • Try to update mysql cookbook to newer version. Installing rubygem has been moved into its own cookbook, is now done in mysql-chef_gem cookbook.

    Best way to manage a cookbook or an application's Cookbook dependencies is to use berkshelf. With berkshelf you can easily vendor your cookbooks per project basis, and then use those vendors versions for provisioning your machine.

    There you can specify version or sha if you pull cookbook directly via git and not from supermarket.