4
votes

I have a Chef custom recipe that uses the Opscode 'database' cookbook. I'm using Chef 11.10 and Berkshelf 3.1.3 in an Opsworks stack and have specified the 'database' cookbook in the Berksfile. It pulls down the dependencies correctly and I can see this in the log. Upon running setup, I get a couple of errors; one about a file not being found (and the path indeed doesn't exist) and another, a 412, about dependency precondition of 'mysql' not being met.

I don't know enough Chef to know if the first error would cause the second failure but it certainy appears that the version of the mysql cookbook required is being met. Is there any known issues with this anyone knows of? Here's the output log of the setup command failing:

[2014-09-29T07:32:17+00:00] INFO: Starting chef-zero on port 8889 with repository at repository at /opt/aws/opsworks/current
One version per cookbook
data_bags at /var/lib/aws/opsworks/data/data_bags
nodes at /var/lib/aws/opsworks/data/nodes

[2014-09-29T07:32:18+00:00] INFO: Forking chef instance to converge...
[2014-09-29T07:32:18+00:00] INFO: *** Chef 11.10.4 ***
[2014-09-29T07:32:18+00:00] INFO: Chef-client pid: 2695
[2014-09-29T07:32:19+00:00] INFO: Setting the run_list to ["opsworks_custom_cookbooks::load", "opsworks_custom_cookbooks::execute"] from JSON
[2014-09-29T07:32:19+00:00] WARN: Run List override has been provided.
[2014-09-29T07:32:19+00:00] WARN: Original Run List: [recipe[opsworks_custom_cookbooks::load], recipe[opsworks_custom_cookbooks::execute]]
[2014-09-29T07:32:19+00:00] WARN: Overridden Run List: [recipe[opsworks_custom_cookbooks::load], recipe[opsworks_custom_cookbooks::execute]]
[2014-09-29T07:32:19+00:00] INFO: Run List is [recipe[opsworks_custom_cookbooks::load], recipe[opsworks_custom_cookbooks::execute]]
[2014-09-29T07:32:19+00:00] INFO: Run List expands to [opsworks_custom_cookbooks::load, opsworks_custom_cookbooks::execute]
[2014-09-29T07:32:19+00:00] INFO: Starting Chef Run for www-prod-migration-3.localdomain
[2014-09-29T07:32:19+00:00] INFO: Running start handlers
[2014-09-29T07:32:19+00:00] INFO: Start handlers complete.
[2014-09-29T07:32:19+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: /reports/nodes/www-prod-migration-3.localdomain/runs
[2014-09-29T07:32:34+00:00] INFO: Loading cookbooks [apache2, dependencies, deploy, gem_support, mod_php5_apache2, mysql, nginx, opsworks_agent_monit, opsworks_aws_flow_ruby, opsworks_berkshelf, opsworks_bundler, opsworks_commons, opsworks_custom_cookbooks, opsworks_initial_setup, opsworks_java, opsworks_nodejs, opsworks_rubygems, packages, passenger_apache2, php, rails, ruby, scm_helper, ssh_users, unicorn]
[2014-09-29T07:32:36+00:00] INFO: Not needed with Chef 11.x (x >= 8) anymore.
[2014-09-29T07:32:36+00:00] INFO: Processing package[git] action install (opsworks_custom_cookbooks::checkout line 11)
[2014-09-29T07:32:38+00:00] INFO: Processing directory[/root/.ssh] action create (opsworks_custom_cookbooks::checkout line 8)
[2014-09-29T07:32:38+00:00] INFO: Processing file[/root/.ssh/config] action touch (opsworks_custom_cookbooks::checkout line 16)
[2014-09-29T07:32:38+00:00] INFO: file[/root/.ssh/config] updated atime and mtime to 2014-09-29 07:32:38 +0000
[2014-09-29T07:32:38+00:00] INFO: Processing execute[echo 'StrictHostKeyChecking no' > /root/.ssh/config] action run (opsworks_custom_cookbooks::checkout line 23)
[2014-09-29T07:32:38+00:00] INFO: Processing template[/root/.ssh/id_dsa] action create (opsworks_custom_cookbooks::checkout line 27)
[2014-09-29T07:32:38+00:00] INFO: Processing git[Download Custom Cookbooks] action checkout (opsworks_custom_cookbooks::checkout line 29)
[2014-09-29T07:32:38+00:00] INFO: Processing ruby_block[Move single cookbook contents into appropriate subdirectory] action run (opsworks_custom_cookbooks::checkout line 64)
[2014-09-29T07:32:38+00:00] INFO: Processing opsworks_berkshelf_runner[Install berkshelf cookbooks] action berks_install (opsworks_berkshelf::install line 54)
[2014-09-29T07:32:38+00:00] INFO: Processing directory[/opt/aws/opsworks/current/berkshelf-cookbooks] action delete (/var/lib/aws/opsworks/cache.stage1/cookbooks/opsworks_berkshelf/providers/runner.rb line 2)
[2014-09-29T07:32:38+00:00] INFO: directory[/opt/aws/opsworks/current/berkshelf-cookbooks] deleted /opt/aws/opsworks/current/berkshelf-cookbooks recursively
[2014-09-29T07:32:38+00:00] INFO: Processing ruby_block[Install the cookbooks specified in the Berksfile and their dependencies] action run (/var/lib/aws/opsworks/cache.stage1/cookbooks/opsworks_berkshelf/providers/runner.rb line 11)
[2014-09-29T07:32:39+00:00] INFO:
Resolving cookbook dependencies...
Using apt (2.6.0)
Using aws (2.4.0)
Using build-essential (2.0.6)
Using chef-sugar (2.3.0)
Using database (2.3.0) from https://github.com/opscode-cookbooks/database.git (at master)
Using mysql (5.5.3)
Using mysql-chef_gem (0.0.5)
Using openssl (2.0.0)
Using postgresql (3.4.6)
Using xfs (1.1.0)
Using yum (3.3.2)
Using yum-mysql-community (0.1.10)
Vendoring apt (2.6.0) to /opt/aws/opsworks/current/berkshelf-cookbooks/apt
Vendoring aws (2.4.0) to /opt/aws/opsworks/current/berkshelf-cookbooks/aws
Vendoring build-essential (2.0.6) to /opt/aws/opsworks/current/berkshelf-cookbooks/build-essential
Vendoring chef-sugar (2.3.0) to /opt/aws/opsworks/current/berkshelf-cookbooks/chef-sugar
Vendoring database (2.3.0) to /opt/aws/opsworks/current/berkshelf-cookbooks/database
Vendoring mysql (5.5.3) to /opt/aws/opsworks/current/berkshelf-cookbooks/mysql
Vendoring mysql-chef_gem (0.0.5) to /opt/aws/opsworks/current/berkshelf-cookbooks/mysql-chef_gem
Vendoring openssl (2.0.0) to /opt/aws/opsworks/current/berkshelf-cookbooks/openssl
Vendoring postgresql (3.4.6) to /opt/aws/opsworks/current/berkshelf-cookbooks/postgresql
Vendoring xfs (1.1.0) to /opt/aws/opsworks/current/berkshelf-cookbooks/xfs
Vendoring yum (3.3.2) to /opt/aws/opsworks/current/berkshelf-cookbooks/yum
Vendoring yum-mysql-community (0.1.10) to /opt/aws/opsworks/current/berkshelf-cookbooks/yum-mysql-community

[2014-09-29T07:32:39+00:00] INFO: ruby_block[Install the cookbooks specified in the Berksfile and their dependencies] called
[2014-09-29T07:32:39+00:00] INFO: Processing execute[ensure correct permissions of custom cookbooks] action run (opsworks_custom_cookbooks::checkout line 82)
[2014-09-29T07:32:39+00:00] INFO: execute[ensure correct permissions of custom cookbooks] ran successfully
[2014-09-29T07:32:39+00:00] INFO: Processing ruby_block[merge all cookbooks sources] action run (opsworks_custom_cookbooks::load line 12)
[2014-09-29T07:32:40+00:00] INFO: ruby_block[merge all cookbooks sources] called
[2014-09-29T07:32:40+00:00] WARN: Skipping final node save because override_runlist was given
[2014-09-29T07:32:40+00:00] INFO: Chef Run complete in 20.634821643 seconds
[2014-09-29T07:32:40+00:00] INFO: Running report handlers
[2014-09-29T07:32:40+00:00] INFO: Report handlers complete

---

[2014-09-29T07:32:42+00:00] INFO: Starting chef-zero on port 8889 with repository at repository at /opt/aws/opsworks/current
One version per cookbook
data_bags at /var/lib/aws/opsworks/data/data_bags
nodes at /var/lib/aws/opsworks/data/nodes

[2014-09-29T07:32:42+00:00] INFO: Forking chef instance to converge...
[2014-09-29T07:32:42+00:00] INFO: *** Chef 11.10.4 ***
[2014-09-29T07:32:42+00:00] INFO: Chef-client pid: 2868
[2014-09-29T07:32:44+00:00] INFO: Setting the run_list to ["opsworks_custom_cookbooks::load", "opsworks_custom_cookbooks::execute"] from JSON
[2014-09-29T07:32:44+00:00] WARN: Run List override has been provided.
[2014-09-29T07:32:44+00:00] WARN: Original Run List: [recipe[opsworks_custom_cookbooks::load], recipe[opsworks_custom_cookbooks::execute]]
[2014-09-29T07:32:44+00:00] WARN: Overridden Run List: [recipe[opsworks_initial_setup], recipe[ssh_host_keys], recipe[ssh_users], recipe[mysql::client], recipe[dependencies], recipe[ebs], recipe[opsworks_ganglia::client], recipe[opsworks_stack_state_sync], recipe[mycustom-setup::nginx], recipe[mycustom-setup::php], recipe[mycustom-setup::nfs], recipe[mycustom-setup::framework], recipe[mycustom-setup::timezone], recipe[mycustom-setup::logrotate], recipe[newrelic::default], recipe[newrelic::php-agent], recipe[database::mysql], recipe[deploy::default], recipe[mycustom-deploy::repository], recipe[mycustom-deploy::nginx-site], recipe[mycustom-deploy::php-site], recipe[test_suite], recipe[opsworks_cleanup]]
[2014-09-29T07:32:44+00:00] INFO: Run List is [recipe[opsworks_initial_setup], recipe[ssh_host_keys], recipe[ssh_users], recipe[mysql::client], recipe[dependencies], recipe[ebs], recipe[opsworks_ganglia::client], recipe[opsworks_stack_state_sync], recipe[mycustom-setup::nginx], recipe[mycustom-setup::php], recipe[mycustom-setup::nfs], recipe[mycustom-setup::framework], recipe[mycustom-setup::timezone], recipe[mycustom-setup::logrotate], recipe[newrelic::default], recipe[newrelic::php-agent], recipe[database::mysql], recipe[deploy::default], recipe[mycustom-deploy::repository], recipe[mycustom-deploy::nginx-site], recipe[mycustom-deploy::php-site], recipe[test_suite], recipe[opsworks_cleanup]]
[2014-09-29T07:32:44+00:00] INFO: Run List expands to [opsworks_initial_setup, ssh_host_keys, ssh_users, mysql::client, dependencies, ebs, opsworks_ganglia::client, opsworks_stack_state_sync, mycustom-setup::nginx, mycustom-setup::php, mycustom-setup::nfs, mycustom-setup::framework, mycustom-setup::timezone, mycustom-setup::logrotate, newrelic::default, newrelic::php-agent, database::mysql, deploy::default, mycustom-deploy::repository, mycustom-deploy::nginx-site, mycustom-deploy::php-site, test_suite, opsworks_cleanup]
[2014-09-29T07:32:44+00:00] INFO: Starting Chef Run for www-prod-migration-3.localdomain
[2014-09-29T07:32:44+00:00] INFO: Running start handlers
[2014-09-29T07:32:44+00:00] INFO: Start handlers complete.
[2014-09-29T07:32:44+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: /reports/nodes/www-prod-migration-3.localdomain/runs
[2014-09-29T07:32:54+00:00] INFO: HTTP Request Returned 412 Precondition Failed: Could not satisfy version constraints for: mysql

================================================================================
Error Resolving Cookbooks for Run List:
================================================================================


Missing Cookbooks:
------------------
Could not satisfy version constraints for: mysql


Expanded Run List:
------------------
* opsworks_initial_setup
* ssh_host_keys
* ssh_users
* mysql::client
* dependencies
* ebs
* opsworks_ganglia::client
* opsworks_stack_state_sync
* mycustom-setup::nginx
* mycustom-setup::php
* mycustom-setup::nfs
* mycustom-setup::framework
* mycustom-setup::timezone
* mycustom-setup::logrotate
* newrelic::default
* newrelic::php-agent
* database::mysql
* deploy::default
* mycustom-deploy::repository
* mycustom-deploy::nginx-site
* mycustom-deploy::php-site
* test_suite
* opsworks_cleanup


[2014-09-29T07:32:55+00:00] ERROR: Running exception handlers
[2014-09-29T07:32:55+00:00] ERROR: Exception handlers complete
[2014-09-29T07:32:55+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2014-09-29T07:32:55+00:00] ERROR: 412 "Precondition Failed"
[2014-09-29T07:32:55+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

here's the Berksfile:

source  "https://supermarket.getchef.com"

cookbook "database" , "= 2.3.0" , git: "https://github.com/opscode-cookbooks/database.git"

here's the interesting part of the metadata for the cookbook:

long_description  IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version           '0.1'
recipe            'mycustom-deploy::cron', 'Set up cron jobs'
recipe            'mycustom::default', 'Returns a fatal error'
recipe            'mycustom::nginx-site', 'configures Nginx for the new site'
recipe            'mycustom::p4ucron', '???'
recipe            'mycustom::php-site', 'Configures php for the new site'
recipe            'mycustom::service', 'Defines services with their allowed parameters'
recipe            'mycustom::repository', '???'

%w{ amazon }.each do |os|
  supports os
end


depends 'mycustom-setup'
depends 'database'

There are also some other custom cookbooks, such as the 'mycustom-setup' which is a dependency for this one. I presume I should look through all of these for clashes?

1
Could you supply your project's Berksfile and a copy of your cookbook's metadata file? Might be a conflict between two cookbooks that you depend on.Mark O'Connor
I've added the details to the original post, Stackoverflow has limits on characters allowed in comments.andyr0ck
Does your environment file contain any limitations on cookbooks? Generally when I see that error it is a result of my environment disagreeing with my cookbook's dependencies.Tejay Cardon
Yes, the "mycustom-setup" cookbook looks like the culprit. Two possibly relevant observations: 1) If you use a "metadata" statement in your Berksfile it would pick up the dependency on "mycustom-setup". 2) You don't need to specify the git URL for the "database" cookbook. In fact you are best advised not to use it. The cookbooks are all revision controlled and available via the supermarket URL.Mark O'Connor
Thanks for the replies, guys. I tried using a Berksfile but AWS handles them slightly differently (one for the entire stack instead of one per cookbook) and despite various tweaks, still got an error for the mysql dependency. In the end, I've opted for carrying out the Mysql elements in a bash script called from the recipe.andyr0ck

1 Answers

1
votes

Check your metadata.rb vs Berksfile cookbooks vs dependencies.

I had the same issue, but within AWS OpsWorks (effectively Chef Solo for this purpose) and the primary problem was rooted in the inclusion of a cookbook in metadata.rb. Removing that resolved the issue. The topic is covered/commented on in this post.