Chef Mysql recipe fails

2019-09-07 15:09发布

Im using the latest Chef 'MYSQL' recipe on Centos7 requiring in a standard role like so

name "lamp"
description "A full lamp server"
run_list "recipe[apache2]", 
         "recipe[apache2::mod_php5]",
         "recipe[apache2::logrotate]",
         "recipe[yum]",
         "recipe[yum-epel]",
         "recipe[mysql::client]",
         "recipe[mysql::server]"
override_attributes({
  "starter_name" => "Jonathan Tizard",
    "mysql" => {
        "server_root_password" => 'iloverandompasswordsbutthiswilldo',
        "server_repl_password" => 'iloverandompasswordsbutthiswilldo',
        "server_debian_password" => 'iloverandompasswordsbutthiswilldo'
    }
})

However I get the following error, am I missing something obvious here? I can't figure out why it is failing. Im thinking I haven't defined a variable or somthing?

Recipe: mysql::server
  * mysql_service[default] action create
  Recipe: yum-mysql-community::mysql55
    * yum_repository[mysql55-community] action create
      * template[/etc/yum.repos.d/mysql55-community.repo] action create (up to date)
      * execute[yum-makecache-mysql55-community] action nothing (skipped due to action :nothing)
      * ruby_block[yum-cache-reload-mysql55-community] action nothing (skipped due to action :nothing)
       (up to date)
    - evaluate block and run any associated actions
    ================================================================================
    Error executing action `create` on resource 'mysql_service[default]'
    ================================================================================

    ArgumentError
    -------------
    You must supply a name when declaring a package resource

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_rhel.rb:168:in `block (2 levels) in <class:Rhel>'
    /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_rhel.rb:153:in `block in <class:Rhel>'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/mysql/recipes/server.rb

     20: mysql_service node['mysql']['service_name'] do
     21:   version node['mysql']['version']
     22:   port node['mysql']['port']
     23:   data_dir node['mysql']['data_dir']
     24:   server_root_password node['mysql']['server_root_password']
     25:   server_debian_password node['mysql']['server_debian_password']
     26:   server_repl_password node['mysql']['server_repl_password']
     27:   allow_remote_root node['mysql']['allow_remote_root']
     28:   remove_anonymous_users node['mysql']['remove_anonymous_users']
     29:   remove_test_database node['mysql']['remove_test_database']
     30:   root_network_acl node['mysql']['root_network_acl']
     31:   version node['mysql']['version']
     32:   action :create
     33: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/mysql/recipes/server.rb:20:in `from_file'

    mysql_service("default") do
      action [:create]
      retries 0
      retry_delay 2
      guard_interpreter :default
      service_name "default"
      version "5.5"
      package_name "mysql55-server"
      data_dir "/var/lib/mysql"
      port "3306"
      remove_anonymous_users true
      remove_test_database true
      server_root_password "iloverandompasswordsbutthiswilldo"
      server_debian_password "iloverandompasswordsbutthiswilldo"
      server_repl_password "iloverandompasswordsbutthiswilldo"
      cookbook_name "mysql"
      recipe_name "server"
    end


Running handlers:
[2014-08-29T21:54:45+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-08-29T21:54:45+00:00] ERROR: Exception handlers complete
[2014-08-29T21:54:45+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 1 resources updated in 9.218038398 seconds
[2014-08-29T21:54:46+00:00] ERROR: mysql_service[default] (mysql::server line 20) had an error: ArgumentError: You must supply a name when declaring a package resource
[2014-08-29T21:54:47+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

1条回答
再贱就再见
2楼-- · 2019-09-07 15:32

See this

The cookbook define the package it should install with a large if/then choice on the OS version.

I think there's something with the centos 7 version parsing causing the error. Maybe you can check the value of platform_version for your node to find why it can't determine the correct package.

查看更多
登录 后发表回答