首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >关于厨师的MySQL食谱不会运行两次

问关于厨师的MySQL食谱不会运行两次
EN

Stack Overflow用户
提问于 2014-07-22 22:39:53
回答 1查看 295关注 0票数 1

我目前正在尝试chef -更准确地说-用它来设置一个简单的灯。我的食谱有时应该包含apache2,mysql和php。现在我被mysql卡住了。

我正在使用的食谱是:https://supermarket.getchef.com/cookbooks/mysql。我的配置与食谱指南页面上的配置几乎相同。

代码语言:javascript
复制
databag_secret = Chef::EncryptedDataBagItem.load_secret("/etc/chef/encrypted_data_bag_secret")
secrets_mysql = Chef::EncryptedDataBagItem.load("secrets", "mysql", databag_secret)

include_recipe "mysql::client"
include_recipe "mysql::server"

mysql_service 'default' do
  allow_remote_root false
  remove_anonymous_users true
  remove_test_database true
  #server_root_password secrets_mysql['mysql_root_pass']
  server_debian_password 'vagrantsuxx'
  action :create
end

从数据包中检索我的秘密工作得很好,并且我的食谱的第一次运行总是通过的。每当我尝试第二次运行它时,都会得到以下错误:

代码语言:javascript
复制
[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上的密码以某种方式被重置。还有谁有过这样的经历?我遗漏了什么?

EN

回答 1

Stack Overflow用户

发布于 2014-11-03 17:53:05

你在用密码吗?

我在那个配置中看不到它

secrets_mysql似乎正在被读取,所以我看不到它正在被操作。它似乎也没有在基本的食谱中使用,所以我不是百分之百地确信密码是进入提供程序加载的。我看到它在你的提供者调用中被注释掉了

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

代码语言:javascript
复制
  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

这就是它被使用的原因

代码语言:javascript
复制
        cmd << "#{pass_string} < /etc/mysql_grants.sql"

因此,资源值的定义如下

代码语言:javascript
复制
    def parsed_server_root_password
  return server_root_password if server_root_password
end

它的默认密码是ilikerandompassword。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24890381

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档