Skip to content

Instantly share code, notes, and snippets.

@lvnilesh
Created November 8, 2012 15:03
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lvnilesh/4039324 to your computer and use it in GitHub Desktop.
Save lvnilesh/4039324 to your computer and use it in GitHub Desktop.
mysql cookbook fails : Chef::Exceptions::Exec: apt-get -q -y install mysql-client=5.5.24-0ubuntu0.12.04.1 returned 100, expected 0
I created a folder for vagrant, edited Vagrantfile, created a cookbooks folder and
git clone https://github.com/opscode-cookbooks/mysql.git
git clone https://github.com/opscode-cookbooks/build-essential.git
git clone https://github.com/opscode-cookbooks/openssl.git
and then vagrant up but chef failed.
[2012-11-08T14:52:50+00:00] INFO: *** Chef 10.14.2 ***
[2012-11-08T14:52:50+00:00] INFO: Setting the run_list to ["recipe[build-essential]", "recipe[openssl]", "recipe[mysql]", "recipe[mysql::client]", "recipe[mysql::server]"] from JSON
[2012-11-08T14:52:50+00:00] INFO: Run List is [recipe[build-essential], recipe[openssl], recipe[mysql], recipe[mysql::client], recipe[mysql::server]]
[2012-11-08T14:52:50+00:00] INFO: Run List expands to [build-essential, openssl, mysql, mysql::client, mysql::server]
[2012-11-08T14:52:50+00:00] INFO: Starting Chef Run for precise64
[2012-11-08T14:52:50+00:00] INFO: Running start handlers
[2012-11-08T14:52:50+00:00] INFO: Start handlers complete.
[2012-11-08T14:52:50+00:00] INFO: Could not find previously defined grants.sql resource
[2012-11-08T14:52:50+00:00] INFO: Processing package[build-essential] action install (build-essential::default line 51)
[2012-11-08T14:52:59+00:00] INFO: Processing package[binutils-doc] action install (build-essential::default line 51)
[2012-11-08T14:53:01+00:00] INFO: Processing package[autoconf] action install (build-essential::default line 58)
[2012-11-08T14:53:04+00:00] INFO: Processing package[flex] action install (build-essential::default line 58)
[2012-11-08T14:53:06+00:00] INFO: Processing package[bison] action install (build-essential::default line 58)
[2012-11-08T14:53:08+00:00] INFO: Processing package[mysql-client] action install (mysql::client line 46)
================================================================================
Error executing action `install` on resource 'package[mysql-client]'
================================================================================
Chef::Exceptions::Exec
----------------------
apt-get -q -y install mysql-client=5.5.24-0ubuntu0.12.04.1 returned 100, expected 0
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/client.rb
45: node['mysql']['client']['packages'].each do |mysql_pack|
46: package mysql_pack do
47: action :install
48: end
49: end
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/client.rb:46:in `from_file'
package("mysql-client") do
retry_delay 2
retries 0
recipe_name "client"
action [:install]
cookbook_name :mysql
package_name "mysql-client"
end
[2012-11-08T14:53:09+00:00] ERROR: Running exception handlers
[2012-11-08T14:53:09+00:00] ERROR: Exception handlers complete
[2012-11-08T14:53:09+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2012-11-08T14:53:09+00:00] FATAL: Chef::Exceptions::Exec: package[mysql-client] (mysql::client line 46) had an error: Chef::Exceptions::Exec: apt-get -q -y install mysql-client=5.5.24-0ubuntu0.12.04.1 returned 100, expected 0
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
@garciaf
Copy link

garciaf commented Dec 21, 2012

Did you solve the problem? I got the same issue...

@ryross
Copy link

ryross commented Jan 10, 2013

I've also just run into this. Any update?

@andreibogdan
Copy link

I have also just run into this. Updates?

@gmanfunky
Copy link

It's like the install command isn't being run with sudo. Trying to figure it out myself, but i'm super new to chef usage.

@gmanfunky
Copy link

A fix is to include_recipe "apt" first. Don't know why this is needed. Guess it is a hidden requirement for the mysql and possibly the nginx module when using Ubuntu 12.04

@marcuscreo
Copy link

Thanks, that did it!

@gondo
Copy link

gondo commented Jun 16, 2013

for whatever reason i have to run apt-get update before almost every (yes multiple times) cookbook (mysql, php, ...) otherwise i get this error ...

@nqsang90
Copy link

thanks. I have recipe "apt", but still got the problem. I do "sudo apt-get update", then I run chef-client. It works nicely.
Unfortunately, I write my own package resource (in my own recipe). I do this, but problem still cannot be solved.

@nforgerit
Copy link

raising the VM's memory from 256M to 1024M solved this issue for me without any calls of apt-get update

@mrded
Copy link

mrded commented Aug 15, 2013

mysql (3.0.0) works fine.

@bensquire
Copy link

mysql (3.0.2) isn't working for me using gem (2.0.7)

@chriscabral
Copy link

I have the same issue. I had to ssh into the box and run "sudo apt-get update" then re-run the config with vagrant reload before my mysql recipe finished. My default recipe has include_recipe 'apt' listed first too. Still does not work. I also made the total ram '4096'.

@jordanmessina
Copy link

This was happening to me when I would use the mysql_database resource. I found that adding notifies :run, 'execute[apt-get update]', :immediately will trigger apt-get update.

mysql_database 'test' do
  notifies :run, 'execute[apt-get update]', :immediately
  connection(
    :host     => 'localhost',
    :username => 'test',
    :password => 'test'
  )
  action :create
end

@defrag
Copy link

defrag commented Jan 12, 2014

Including apt-get update on compile time with one of your recipes also helps. (But this is database cookbook error related) This worked for me:

execute "compile-time-apt-get-update" do 
  command "apt-get update" 
  ignore_failure true 
  action :nothing 
end.run_action(:run) 

include_recipe "mysql::server"
include_recipe "mysql::client"
include_recipe "database"
include_recipe "mysql::ruby"

@wkhatch
Copy link

wkhatch commented May 15, 2014

can anybody explain what the underlying nature of the problem is? I've hit this issue, with the mysql cookbook, so many times it's pretty much wiped out any time advantage when using chef for the rest of my life. Seriously, the time I spend getting past this pretty much triples what it would take to just install everything by hand. And that doesn't include the giant time suck with learning chef itself. Is the problem with the mysql cookbook? Or the apt cookbook? Or some issue with the apt repositories? I've used every trick in the fucking book to get apt recipe to update, and I'll still hit this. Sometimes, it actually works though. Most annoying is when you get it working in an app cookbook, and then a few months later, you use the exact same recipe on a new box, and you hit it again. Can anybody explain what the fuck, exactly, is the deal with this? As you can probably guess, I'm in the midst of it yet again, right now... ;-)

@devjj
Copy link

devjj commented May 20, 2014

@wkhatch: I'm in the same boat here. I've reviewed dozens of tutorials that all say "include apt::default early in your run list" but I continue to run into this issue. It's pathetic that there's no clear answer to this anywhere.

@bhagany
Copy link

bhagany commented Jul 2, 2014

I've spent a long time on this problem, and I finally found some relevant discussions. I'm going to link to them here because this gist seems to rank pretty highly for whatever I searched:

chef-boneyard/build-essential#32
sous-chefs/apt#75
https://tickets.opscode.com/browse/COOK-4534

The basic thing that's happening here is that build-essential (usually - it could be another cookbook) is running at chef compile time, before chef gets around to actually executing the run_list. They've added an option to the apt cookbook to fix this, apparently.

In my case, I wasn't aware that an attributes file in an unrelated cookbook (an old version of the elasticsearch cookbook) was setting build-essential's compile_time attribute to true. Removing that fixed this problem for me, because build-essential would no longer run at compile time, and therefore apt would have a chance to run and update its cache (it's first in my run_list).

I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment