Installing mysql2 gem in vagrant via chef-solo - ruby

I'm trying to install mysql2 gem in my vagrant machine with chef solo. I am getting the following error
ERROR: mysql2_chef_gem_installer[default] (mysql2_chef_gem::default line 20) had an error:
Chef::Exceptions::RecipeNotFound: could not find recipe client for cookbook mysql
I have included the cookbook mysql and the dependencies are added in the metadata.rb
Following is the code snippet
mysql2_chef_gem_installer 'default' do
type 'mysql'
action :install
end
Could somebody explain what is it I am doing wrong ?

Related

Using a chef cookbook in my own cookbook error

So I am new to chef and want to use chef-patch in my own recipes. I added cookbook 'patch', '~> 2.2.1' to my Berksfile and did sudo berks install
and it installs it. But when I run my recipe it says ERROR: undefined method 'replace' for #<Chef::Recipe:0x00000003cab450>
Is there something I need to add to my fix.rb code.
replace "/etc/login.defs" do
replace "PASS_MAX_DAYS 60"
with "PASS_MAX_DAYS 59"
end
There is no direct link between Berkshelf and either of those. You need to use berks upload to send things to the Chef server for use with chef-client, and for chef-solo the workflow is up to you (though will probably involve berks vendor to write the cookbooks out at some point). You also need depends 'patch' in your metadata.rb.

chef windows_package encoding errors

I am trying to use Chef to install R onto windows 7.
I installed chef_handler and windows using knife
knife cookbook site install windows
knife cookbook site install chef_handler
and created a new cookbook
chef generate cookbook cookbooks/awesome_machine_config
inside default.rb I have
windows_package 'R for Windows 3.3.2' do
source 'd:/Downloads/R-3.3.2-win.exe'
action :install
end
inside metadata.rb
I have:
depends 'windows'
when I run:
chef-client --local-mode recipe[awesome_machine_config]
It synchronises the cookbooks fine and installs the cookbook gems fine.
But then I get a:
Error executing action `install` on resource 'windows_package[R for Windows 3.3.2]'
Encoding::InvalidByteSequenceError
incomplete "\x00" on UTF-16LE
chef is running as administrator so shouldn' be a permissions fault?
Any ideas how to debug?

chef-solo with vagrant "LoadError cannot load such file -- mysql2"

Vagrant provision throws this error
Error executing action drop on resource 'mysql_database[database_name]'
LoadError
cannot load such file -- mysql2
My code snippet which throws the error is as follows
mysql_database node['mysql_database'] do
connection mysql_connection_info
action [:drop,:create]
end
My cookbook is installing mysql2 gem in the vagrant machine.
vagrant#ubuntu-14:~$ gem list --local
mysql2 (0.4.1, 0.4.0)
I couldn't figure out why is it still not able to load the mysql2 gem. Any help is appreciated.

"Kitchen list" command fails with "Could not load the 'ssh' transport from the load path"

I'm trying to add a Test Kitchen to a Chef cookbook but am getting the error "Could not load the 'ssh' transport from the load path".
I have previously set up a Test Kitchen following the exact same steps without issue, but that was on a different machine.
I've tried running
gem install net-ssh
But that doesn't seem to fix the problem
Solved it.
I ran
gem list
Which gave the output
..
net-ssh (2.10.0.beta2, 2.9.2)
..
I then issued the command:
gem uninstall net-ssh 2.10.9.beta2
And got the output:
Select gem to uninstall:
1. net-ssh-2.10.0.beta2
2. net-ssh-2.9.2
3. All versions
Whereupon I selected option 1, the gem was removed and then running
kitchen list
Worked as expected
I was running into the same problem for Java SE Chef cookbook on Travis-CI with:
Chef Development Kit Version: 0.10.0
chef-client version: 12.6.0
berks version: 4.0.1
kitchen version: 1.5.0
Throwing this:
-----> Starting Kitchen (v1.5.0)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ClientError
>>>>>> Message: Could not load the 'ssh' transport from the load path. Please ensure that your transport is installed as a gem or included in your Gemfile if using Bundler.
>>>>>> ----------------------
I had to switch to Dokken to get it to work:
https://github.com/someara/kitchen-dokken
To fix:
Update .travis.yml to install kitchen-dokken:
/opt/chefdk/embedded/bin/chef gem install kitchen-dokken
And update .kitchen.docker.yml with:
transport:
name: dokken
provisioner:
name: dokken
verifier:
root_path: '/opt/verifier'
sudo: false
driver:
name: dokken

chef gem_package not using the right binary

I'm trying to install the gems "sensu_plugin" and "mixlib-shellout", on a windows server 2008r2, from a recipe. In this last one, I have the following code :
%w{ sensu-plugin mixlib-shellout }.each do |gem_plugin|
gem_package gem_plugin do
gem_binary("C:/opt/sensu/embedded/bin/gem")
options("--no-rdoc --no-ri")
action :install
end
end
Yet, when running the recipe on my machine, I receive the error "ERROR: While executing gem ... (Errno::ENOENT) No such file or directory - U:/". What I found out is that whenever I try installing a gem package using the gem binary located in the chef-client directory (C:\opscode\chef\embedded\bin\gem), it raised this last error.
The thing is that the gem I wish to use to installed the gem packages is actually located in C:/opt/sensu/embedded/bin/gem, which I have declared in the gem_binary option.
In the end it looks like chef is ignoring the gem_binary option and trying to install it from its own gem binary.
I can't see what's wrong with this config. Is the gem_binary really indicating what binary to use?

Resources