Mysql Service Recipe抛出未定义的方法错误

时间:2016-01-17 17:07:47

标签: mysql chef chef-solo

我尝试使用主厨mysql recipe,但我一直收到错误undefined method '[]' for nil:NilClass

mysql.rb

mysql_service 'mysql' do
  port '3306'
  version '5.7.10'
  initial_root_password 'SuperSecretPassword'
  action [:create, :start]
end

mysql_config 'foo' do
  source 'wp-config.php.erb'
  notifies :restart, 'mysql_service[mysql]'
  action :create
end

错误日志

Recipe: wp::mysql
  * mysql_service[mysql] action create

    ================================================================================
    Error executing action `create` on resource 'mysql_service[mysql]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `[]' for nil:NilClass

    Cookbook Trace:
    ---------------
    /root/chef-solo/cookbooks-2/mysql/libraries/helpers.rb:380:in `package_name_for'
    /root/chef-solo/cookbooks-2/mysql/libraries/helpers.rb:421:in `server_package'
    /root/chef-solo/cookbooks-2/mysql/libraries/helpers.rb:432:in `server_package_name'
    /root/chef-solo/cookbooks-2/mysql/libraries/provider_mysql_service_base.rb:31:in `block in <class:MysqlServiceBase>'

    Resource Declaration:
    ---------------------
    # In /root/chef-solo/cookbooks-3/wp/recipes/mysql.rb

      5: mysql_service 'mysql' do
      6:   port '3306'
      7:   version '5.7.10'
      8:   initial_root_password 'ZH9D3nHE9gm1gFIgKdDC'
      9:   action [:create, :start]
     10: end
     11: 

    Compiled Resource:
    ------------------
    # Declared in /root/chef-solo/cookbooks-3/wp/recipes/mysql.rb:5:in `from_file'

    mysql_service("mysql") do
      action [:create, :start]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :mysql_service
      cookbook_name :wp
      recipe_name "mysql"
      port "3306"
      version "5.7.10"
      initial_root_password "ZH9D3nHE9gm1gFIgKdDC"
    end


Running handlers:
[2016-01-17T12:04:43-05:00] ERROR: Running exception handlers
Running handlers complete
[2016-01-17T12:04:43-05:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 04 seconds
[2016-01-17T12:04:43-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-01-17T12:04:43-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-01-17T12:04:43-05:00] ERROR: mysql_service[mysql] (wp::mysql line 5) had an error: NoMethodError: undefined method `[]' for nil:NilClass
[2016-01-17T12:04:43-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ERROR: RuntimeError: chef-solo failed. See output above.

1 个答案:

答案 0 :(得分:0)

该方法涉及查找当前平台的包名称等。可能意味着你正在尝试使用OS /发行版,食谱不支持。