0
votes

I try to install MySQL Community Server on CentOS7 using Chef mysql cookbook from supermarket: https://supermarket.chef.io/cookbooks/mysql

My cookbook files:

metadata.rb

depends 'mysql', '~> 8.0.4'

default.rb

mysql_service 'db_some_data' do
  port '3306'
  version '5.7'
  initial_root_password 'abc123'
  action [:create, :start]
end

I executed:

berks install
kitchen test -d never

and got following error:

================================================================================
Error executing action `install` on resource 'yum_package[mysql-community-server]'
================================================================================

Chef::Exceptions::Package
-------------------------
No candidate version available for mysql-community-server

    Resource Declaration:
    ---------------------
    # In /tmp/kitchen/cache/cookbooks/mysql/libraries/mysql_server_installation_package.rb

     17:       package package_name do
     18:         version package_version if package_version
     19:         options package_options if package_options
     20:         notifies :install, 'package[perl-Sys-Hostname-Long]', :immediately if plaform_family?('suse')
     21:         notifies :run, 'execute[Initial DB setup script]', :immediately if platfom_family?('suse')
     22:         action :install
     23:       end
     24:

    Compiled Resource:
    ------------------
    # Declared in /tmp/kitchen/cache/cookbooks/mysql/libraries/mysql_server_installation_pckage.rb:17:in `block in <class:MysqlServerInstallationPackage>'

    yum_package("mysql-community-server") do
      package_name "mysql-community-server"
      action [:install]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :package
      cookbook_name "obiwan"
      version "5.7.11-1.el7"
      flush_cache {:before=>false, :after=>false}
    end

    Platform:
    ---------
    x86_64-linux

It looks like this issue: https://github.com/chef-cookbooks/mysql/issues/443

Thanks for your time!

3

3 Answers

0
votes

I suspect you may need to use a different cookbook for this as the command below doesn't show mysql-community-server in the centos 7 repo. Perhaps try the mariadb cookbook.

yum provides mysql*

However if you really have to install mysql-community-server, you probably need to modify your recipe to look like so

execute 'mysql-community-repo' do
 command 'yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
 action :run
end

 mysql_service 'db_some_data' do
  port '3306'
  version '5.7'
  initial_root_password 'abc123'
  action [:create, :start]
 end   

Keep in mind, you may encounter some issues with the systemctl init script when starting mysql-community.

0
votes

I managed to fix this setup with following changes:

metadata.rb

depends 'mysql'
depends 'mysql2_chef_gem'
depends 'database'

default.rb

mysql_client 'default' do
  action :create
end

mysql_service 'db_some_data' do
  port '3306'
  version '5.7'
  initial_root_password 'abc123'
  action [:create, :start]
end

mysql2_chef_gem 'default' do
  action :install
end
0
votes

The problem exists because https://supermarket.chef.io/cookbooks/mysql doesn't yet support for

cookbook 'mysql', '~> 8.0'

I added the following dependencies and it worked fine.

cookbook "yum-mysql-community", '~> 4.0.1'
cookbook 'mysql', '~> 6.0'
cookbook 'yum-centos', '~> 3.0.0'

Another thing to note here is to remember providing the package_name in the recipe. My recipe looks like this:

mysql_service 'foo' do
  port '3306'
  version '5.7'
  package_name 'mysql-server' 
  initial_root_password 'root'
  action [:create, :start]
end

Hope it helps!