【问题标题】:Vagrant + Chef box throwing "uninitialized constant Opscode::Mysql"Vagrant + Chef 框抛出“未初始化的常量 Opscode::Mysql”
【发布时间】:2015-01-13 05:12:49
【问题描述】:

这是相关框的vagrant up(在vagrant destroy 之后)的输出(vagrant provision 导致相同的错误):

==> mongos-zend: ================================================================================
==> mongos-zend: Recipe Compile Error in /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_debian.rb
==> mongos-zend: ================================================================================
==> mongos-zend: 
==> mongos-zend: 
==> mongos-zend: NameError
==> mongos-zend: ---------
==> mongos-zend: uninitialized constant Opscode::Mysql
==> mongos-zend: 
==> mongos-zend: 
==> mongos-zend: Cookbook Trace:
==> mongos-zend: ---------------
==> mongos-zend:   /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_debian.rb:17:in `<class:Debian>'
==> mongos-zend:   /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_debian.rb:9:in `<class:MysqlService>'
==> mongos-zend:   /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_debian.rb:8:in `<class:Provider>'
==> mongos-zend:   /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_debian.rb:7:in `<class:Chef>'
==> mongos-zend:   /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_debian.rb:6:in `<top (required)>'
==> mongos-zend: 
==> mongos-zend: 
==> mongos-zend: Relevant File Content:
==> mongos-zend: ----------------------
==> mongos-zend: /var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_debian.rb:
==> mongos-zend: 
==> mongos-zend:  10:          use_inline_resources if defined?(use_inline_resources)
==> mongos-zend:  11:  
==> mongos-zend:  12:          def whyrun_supported?
==> mongos-zend:  13:            true
==> mongos-zend:  14:          end
==> mongos-zend:  15:  
==> mongos-zend:  16:          include MysqlCookbook::Helpers::Debian
==> mongos-zend:  17>>         include Opscode::Mysql::Helpers
==> mongos-zend:  18:  
==> mongos-zend:  19:          action :create do
==> mongos-zend:  20:  
==> mongos-zend:  21:            unless sensitive_supported?
==> mongos-zend:  22:              Chef::Log.debug("Sensitive attribute disabled, chef-client version #{Chef::VERSION} is lower than 11.14.0")
==> mongos-zend:  23:            end
==> mongos-zend:  24:  
==> mongos-zend:  25:            package 'debconf-utils' do
==> mongos-zend:  26:              action :install
==> mongos-zend: 
==> mongos-zend: 
==> mongos-zend: 
==> mongos-zend: [2015-01-12T10:50:04-06:00] ERROR: Running exception handlers
==> mongos-zend: [2015-01-12T10:50:04-06:00] ERROR: Exception handlers complete
==> mongos-zend: [2015-01-12T10:50:04-06:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> mongos-zend: [2015-01-12T10:50:04-06:00] ERROR: uninitialized constant Opscode::Mysql
==> mongos-zend: [2015-01-12T10:50:04-06:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

$ 厨师客户 -v 厨师:11.18.0.rc.1

$ 流浪者 -v 流浪者 1.6.5

这本食谱正在通过 berks 超市送来,这让我很受用 - https://github.com/chef-cookbooks/mysql

如果有人对添加内容有建议,我可以提供更多信息。我希望有人看到这一点并认识到这个问题并知道要寻找什么。

Shyamalan 式的转折:我的同事正在使用与我相同的 Vagrant/Chef 存储库,并且可以毫无问题地运行 vagrant up。我们拥有相同版本的 Vagrant 和 Chef,其他所有内容都应通过 Berksfile/Vagrantfile(位于 repo 中)进行管理。

【问题讨论】:

  • 你是如何安装说明书的?
  • @hek2mgl 所有的食谱都由 berks 管理,所以如果我做一个berks list,我会得到一堆食谱,包括* mysql (6.0.6),这似乎是个麻烦点。
  • 你能确认“Opscode:Mysql:Helper”不在你的cookbooks文件夹中吗?
  • @hek2mgl 文件 helpers.rb 出现在食谱中(如果你是这个意思)。

标签: vagrant chef-infra berkshelf chef-zero


【解决方案1】:

您的代码依赖于 &lt; 6.0 版本中的 mysql cookbook

查看helper library in v5.6.1,它位于Opscode::Mysql::Helpers 命名空间中,而helper library in v6.0.0 位于MysqlCookbook::Helpers 中。

如果您有自己的顶级食谱,我不确定您的运行清单是什么,但您可以在metadata.rbdepends 部分定义版本约束(请参阅docs)。

【讨论】:

  • 这看起来很有希望 - 现在正在调查。如果是这种情况,为什么我会遇到这个问题,而使用相同 repo 的其他人没有这个问题?感谢您的回答,如果有效,我会更新!
  • 我也不确定,看起来很奇怪。因为您的日志显示的代码 sn-p 来自 5.x 版本,而不是来自 6.x。你把你的 berkshelf 商店弄乱了(在 `~/.berkshelf/cookbooks 中) - 也许从那里删除食谱?
  • 我仍在运行vagrant up 进行确认,但根据您的建议,我的 ~/.berkshelf/cookbooks 目录中的rm -rf mysql-6.0.6 和我的项目中的rm -rf /chef-cookbooks。然后我运行了vagrant destroy &amp;&amp; vagrant up。看起来这可能已经解决了这个问题。就好像我的目录中的 mysql-6.0.6 实际上是别的东西,或者是错误的?我不知道...
  • 轰隆隆。那解决了它。 berks list 输出没有改变,ls chef-cookbooks/ls ~/.berkshelf/cookbooks/ 的内容也没有改变,但是在执行上述删除步骤后,我不再收到该错误。谢谢!
【解决方案2】:

刚刚查看了我们的包含 - 我们引用了所有食谱名称。我会从那里开始。

另一件事可能是区分大小写——取决于可以发挥作用的主机文件系统。

【讨论】:

  • 我认为这不是问题,因为有问题的代码来自该 opscode git repo。这不是我写的。我希望如果它被打破,这个问题会更广泛地传播。此外,我没有遇到此问题的同事正在运行相同的 mac。不过谢谢!
猜你喜欢
  • 2014-07-03
  • 2015-04-14
  • 2015-04-21
  • 1970-01-01
  • 1970-01-01
  • 2017-11-22
  • 2016-03-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多