mysql - Chef 客户端在处理 MySQL Recipe 期间出现错误

标签 mysql ruby chef-infra cookbook

我正在尝试使用 Chef 客户端配置新服务器。该过程遇到由未初始化常量“MysqlCookbook:Helpers”引起的 NameError。

这是我得到的输出:

0.0.0.0 Compiling Cookbooks...
0.0.0.0
0.0.0.0 ================================================================================
0.0.0.0 Recipe Compile Error in /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_client.rb
0.0.0.0 ================================================================================
0.0.0.0
0.0.0.0 NameError
0.0.0.0 ---------
0.0.0.0 uninitialized constant MysqlCookbook::Helpers
0.0.0.0
0.0.0.0 Cookbook Trace:
0.0.0.0 ---------------
0.0.0.0   /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_client.rb:7:in `<class:MysqlClient>'
0.0.0.0   /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_client.rb:6:in `<class:Provider>'
0.0.0.0   /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_client.rb:5:in `<class:Chef>'
0.0.0.0   /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_client.rb:4:in `<top (required)>'
0.0.0.0
0.0.0.0 Relevant File Content:
0.0.0.0 ----------------------
0.0.0.0 /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_client.rb:
0.0.0.0
0.0.0.0   1:  require 'chef/provider/lwrp_base'
0.0.0.0   2:  require_relative 'helpers'
0.0.0.0   3:
0.0.0.0   4:  class Chef
0.0.0.0   5:    class Provider
0.0.0.0   6:      class MysqlClient < Chef::Provider::LWRPBase
0.0.0.0   7>>       include MysqlCookbook::Helpers
0.0.0.0   8:        provides :mysql_client if defined?(provides)
0.0.0.0   9:
0.0.0.0  10:        use_inline_resources if defined?(use_inline_resources)
0.0.0.0  11:
0.0.0.0  12:        def whyrun_supported?
0.0.0.0  13:          true
0.0.0.0  14:        end
0.0.0.0  15:
0.0.0.0  16:        action :create do
0.0.0.0
0.0.0.0 System Info:
0.0.0.0 ------------
0.0.0.0 chef_version=12.21.31
0.0.0.0 platform=ubuntu
0.0.0.0 platform_version=16.04
0.0.0.0 ruby=ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
0.0.0.0 program_name=chef-client worker: ppid=31986;start=12:48:17;
0.0.0.0 executable=/opt/chef/bin/chef-client
0.0.0.0
0.0.0.0
0.0.0.0 Running handlers:
0.0.0.0 [2018-02-07T12:48:23+00:00] ERROR: Running exception handlers
0.0.0.0 Running handlers complete
0.0.0.0 [2018-02-07T12:48:23+00:00] ERROR: Exception handlers complete
0.0.0.0 Chef Client failed. 0 resources updated in 05 seconds
0.0.0.0 [2018-02-07T12:48:23+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
0.0.0.0 [2018-02-07T12:48:23+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
0.0.0.0 [2018-02-07T12:48:23+00:00] ERROR: uninitialized constant MysqlCookbook::Helpers
0.0.0.0 [2018-02-07T12:48:23+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

我查看了似乎正在崩溃的文件(provider_mysql_client.rb),该文件以以下代码开始:

require 'chef/provider/lwrp_base'
require_relative 'helpers'

class Chef
  class Provider
    class MysqlClient < Chef::Provider::LWRPBase
      include MysqlCookbook::Helpers
      provides :mysql_client if defined?(provides)

我不是 Ruby 开发人员(我的背景是 PHP 和 JavaScript),但在我看来,它包含文件 helpers.rb,该文件与上述文件位于同一目录中。

其内容如下所示:

module MysqlCookbook
  module HelpersBase
    require 'shellwords'

    def el6?
      return true if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 6
      false
    end

对我来说,这看起来与上面引用 MysqlCookbook::Helpers 的 include 语句不一致 - 这看起来应该被称为 MysqlCookbook::HelpersBase (同样,我不是 Ruby 开发人员,所以我可能会在这里弄错) .

我不太确定如何继续推进并让 Chef 客户端运行成功完成。我在 Recipe GitHub 上发现了以下问题 - https://github.com/chef-cookbooks/mysql/issues/540这似乎与我遇到的情况相符,但它没有任何回复,所以对我来说不是特别有用。

感谢任何意见/建议,谢谢。

最佳答案

文件provider_mysql_client.rb在说明书的8.x.x版本中不再存在。

确保您没有来自以前版本 7.x.x 的 Recipe 的旧文件。

如果您正在使用 Berkshelf,请尝试删除其缓存 (~/.berkself)。

如果您要将所有内容复制到目标服务器,然后使用 Chef 零 (-z),也请查看那里。

关于mysql - Chef 客户端在处理 MySQL Recipe 期间出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48665297/

相关文章:

ruby-on-rails - 使用 YAJL 在 Rails 中拉取流式 API

php - 如何在 MySQL 数据库中存储包含引号的字符串?

Mysql 选择具有不同选项的查询

ruby - Rails 3.1 Rspec 为模型创建测试用例验证字段

ruby - 如何使用数组元素在 Ruby 中创建文件名?

ubuntu - 通过 Chef 执行 add-apt-repository 的正确方法是什么?

chef-infra - Chef : How to rollback a run of cookbook?

chef-infra - 为什么我不能在 Chef Recipe 中使用属性作为资源名称?

php - laravel 和 artisan 错误无法在迁移时添加外键

mysql - 每个 GROUP BY 表达式必须包含不是外部引用的列