【发布时间】:2016-10-12 07:15:43
【问题描述】:
我正在使用 chef_solo 配置器配置 Vagrant bento/centos6.7 框。我将 berkshelf-plugin 用于说明书依赖项。
我的项目文件夹如下所示:
|── Vagrantfile
|── cookbooks
└── my_cookbook
|── Berksfile
|── metadata.rb
...
在我的Vagrantfile 中(这是bento/centos6.7 的默认值加上以下配置)
config.berkshelf.enabled = true
config.berkshelf.berksfile_path = "cookbooks/my_cookbook/Berksfile"
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "my_cookbook"
end
在我的metadata.rb
depends 'mysql2_chef_gem', '~> 1.1'
depends 'database', '~> 5.1'
当我配置我的流浪机器时,我收到以下错误:
Error executing action `create` on resource 'mysql_database[my_database]'
Mysql2::Error
-------------
Lost connection to MySQL server at 'reading initial communication packet', system error: 110
PS:它在bento/centos7.2上完美运行
编辑:这是数据库创建部分:
# Install the MySQL client
mysql_client 'default' do
action :create
end
# Configure the MySQL service
mysql_service 'default' do
initial_root_password node['webserver']['database']['root_password']
action [:create, :start]
end
# Install the mysql2 Ruby gem
mysql2_chef_gem 'default' do
action :install
end
mysql_database node['webserver']['database']['db_name'] do
connection(
:host => node['webserver']['database']['host'],
:username => node['webserver']['database']['root_username'],
:password => node['webserver']['database']['root_password']
)
action :create
end
编辑 2: 它实际上不适用于 bento/centos7.2。它不会崩溃,但 MySQL 似乎已经死了并且正在运行 sudo systemctl start mysqld 挂起。
【问题讨论】:
-
您能在此处粘贴具有
mysql_database资源的配方部分吗? -
@zuazo 我更新了我的问题,提供了代码。
标签: vagrant chef-infra chef-solo