Vagrant Chef上的MySQL cookbook不会运行两次

Vagrant Chef上的MySQL cookbook不会运行两次,vagrant,chef-infra,chef-recipe,Vagrant,Chef Infra,Chef Recipe,我目前正在尝试厨师-更准确地说-设置一个简单的灯与它。我的烹饪书有时应该包含apache2、mysql和php。现在我被mysql困住了 我正在使用的食谱:。我的配置与烹饪指南页面上的配置几乎相同 databag\u secret=Chef::EncryptedDataBagItem.load\u secret/etc/Chef/encrypted\u data\u bag\u secret secrets\u mysql=Chef::EncryptedDataBagItem.loadsecre

我目前正在尝试厨师-更准确地说-设置一个简单的灯与它。我的烹饪书有时应该包含apache2、mysql和php。现在我被mysql困住了

我正在使用的食谱:。我的配置与烹饪指南页面上的配置几乎相同

databag\u secret=Chef::EncryptedDataBagItem.load\u secret/etc/Chef/encrypted\u data\u bag\u secret secrets\u mysql=Chef::EncryptedDataBagItem.loadsecrets,mysql,databag\u secret include\u配方mysql::客户端 include_recipe mysql::server mysql_服务“默认”do 允许\u远程\u根错误 删除\u匿名\u用户为true 删除\u测试\u数据库为true 服务器\u root\u密码机密\u mysql['mysql\u root\u pass'] 服务器\u debian\u密码“Vagarantsuxx” 行动:创建 终止 从资料袋中找回我的秘密效果很好,我的烹饪书的第一次运行总是通过的。每当我第二次尝试运行它时,它都会出现以下错误:

[2014-07-22T14:32:01+00:00] ERROR: Running exception handlers
Running handlers complete

[2014-07-22T14:32:01+00:00] ERROR: Exception handlers complete
[2014-07-22T14:32:01+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 5 resources updated in 6.99007798 seconds
[2014-07-22T14:32:01+00:00] ERROR: mysql_service[default] (mysql::server line 20) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[install-grants] (/var/chef/cache/cookbooks/mysql/libraries/provider_mysql_service_ubuntu.rb line 91) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/bin/mysql -u root -pilikerandompasswords < /etc/mysql_grants.sql ----
STDOUT:
STDERR: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
---- End output of /usr/bin/mysql -u root -pilikerandompasswords < /etc/mysql_grants.sql ----
Ran /usr/bin/mysql -u root -pilikerandompasswords < /etc/mysql_grants.sql returned 1
[2014-07-22T14:32:01+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

我想知道这是为什么。/etc/mysql_grants.sql上的密码不知怎么被重置了。还有其他人经历过吗?我遗漏了什么?

您在使用密码吗

在那个配置中我看不到它

mysql的秘密似乎正在被读取,但我看不到它正在被操作。它似乎也没有在基本烹饪书中使用,所以我不能100%确信密码正在进入要加载的提供程序。我看到你的服务提供商电话里有评论

下面显示了在服务提供商使用debian helper之前,密码字符串是如何在debian helper中构建的

  def pass_string
    if new_resource.parsed_server_root_password.empty?
      pass_string = ''
    else
      pass_string = '-p' + Shellwords.escape(new_resource.parsed_server_root_password)
    end

    pass_string = '-p' + ::File.open('/etc/.mysql_root').read.chomp if ::File.exist?('/etc/.mysql_root')
    pass_string
  end
这就是当时正在使用的

        cmd << "#{pass_string} < /etc/mysql_grants.sql"
默认值为ilikerandompasswords


当您使用databag值取消对行的注释时会发生什么情况?

您的食谱中是否有在/etc/mysql\u grants.sql中设置密码的地方?chef stacktrace.out中还有更多细节吗?如前所述,您看到的小东西是我的整个配置。除了一些数据包JSON之外,我没有接触过任何其他文件。所以我的食谱不能修改mysql_grants.sql中的密码。我必须承认我对mysql_grants.sql文件不太熟悉。MySQL真的在这样的普通文件中存储权限吗?因此,您在每次运行后都会检查文件的内容,并且每次运行后都会有所不同?stacktrace.out文件就链接在这里:感谢您的链接,排除隐藏的问题总是很好的。第二次运行后,您可以手动使用MySQL进行身份验证吗?或者权限是否已完全擦除/更改?
    def parsed_server_root_password
  return server_root_password if server_root_password
end