0

Basically I want to create a cookbook that installs MySQL 5.7 so I though I would utilize mysql from the supermarket.

I started off by creating a fresh cookbook using chef generate cookbook MYSQL Then added depends 'mysql', '~> 8.0' and run a berks install which runs successfully and installs the mysql cookbook.

Here is my default.rb

mysql_service 'default' do
 version '5.7'
 bind_address '0.0.0.0'
 port '3306'
 data_dir '/data'
 initial_root_password 'vagrant'
 action [:create, :start]
end

I run this command to run the cookbook - sudo chef-client --local recipes/default.rb which gives me the following output

[2017-08-23T18:54:31+00:00] INFO: Started chef-zero at chefzero://localhost:1 with repository at /home/vagrant
One version per cookbook
[2017-08-23T18:54:31+00:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 13.2.20
[2017-08-23T18:54:31+00:00] INFO: *** Chef 13.2.20 ***
[2017-08-23T18:54:31+00:00] INFO: Platform: x86_64-linux
[2017-08-23T18:54:31+00:00] INFO: Chef-client pid: 26421
[2017-08-23T18:54:31+00:00] INFO: The plugin path /etc/chef/ohai/plugins does not exist. Skipping...
[2017-08-23T18:54:33+00:00] INFO: Run List is []
[2017-08-23T18:54:33+00:00] INFO: Run List expands to []
[2017-08-23T18:54:33+00:00] INFO: Starting Chef Run for ardent-admin
[2017-08-23T18:54:33+00:00] INFO: Running start handlers
[2017-08-23T18:54:33+00:00] INFO: Start handlers complete.
resolving cookbooks for run list: []
[2017-08-23T18:54:33+00:00] INFO: Loading cookbooks []
Synchronizing Cookbooks:
Installing Cookbook Gems:
Compiling Cookbooks...

Running handlers:
[2017-08-23T18:54:33+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-08-23T18:54:33+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2017-08-23T18:54:33+00:00] FATAL: Stacktrace dumped to 
/home/vagrant/.chef/local-mode-cache/cache/chef-stacktrace.out
[2017-08-23T18:54:33+00:00] FATAL: Please provide the contents of the 
stacktrace.out file if you file a bug report
[2017-08-23T18:54:33+00:00] ERROR: undefined method `mysql_service' for #<Chef::Recipe:0x00000004e58a68>
[2017-08-23T18:54:33+00:00] FATAL: 
Chef::Exceptions::ChildConvergeError: Chef run process exited 
unsuccessfully (exit code 1)
Dylan
  • 101
  • 4

1 Answers1

0

I'm 99% sure you cross-posted this somewhere else and I answered it there too, but just in case: running a single recipe like that doesn't process dependencies. You need to use the normal mode of chef-solo (or chef-client local mode, but probably solo). Unfortunately you don't give enough info here to know what that would look like. Solo-based workflows are always more complex because you're off the normal beaten path. We recommend you stick to the standard workflows as much as possible, until you're familiar enough with Chef to make your own trail.

coderanger
  • 836
  • 4
  • 13