I am trying to create a cookbook wrapper to deploy MySQL with Chef, but it seems that it does not insert the initial root password that I am setting in my cookbook.
mysql_client 'default' do
version '5.6'
action :create
end
if node['kaltiot_mysql']['deployServer'] == 'true'
#-------------------------------------------
# Create the database server and start it
#-------------------------------------------
mysql_service 'default' do
port '3306'
version '5.6'
initial_root_password node['mysql']['initial_root_password']
action [:create, :start]
end
#-------------------------------------------
# Create the database and the user to access
#-------------------------------------------
include_recipe 'database::mysql'
connection_params = {
:host => 'localhost',
:username => 'root',
:password => node['mysql']['initial_root_password']
}
mysql_database 'test' do
connection connection_params
action :create
end
mysql_database_user 'usertest' do
connection connection_params
password node['mysql']['initial_root_password']
privileges [:all]
action [:create, :grant]
end
end
My environment is the following:
- Chef 12.0.3
- Berkshelf 3.2.1
- Kitchen 1.2.1
- Vagrant 1.6.5
- Virtual box: Centos 6.6 (http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.6_chef-provisionerless.box)
The cookbooks that I am using are the latest releases:
- mysql 6.0.7
- database 3.0.0
As the initial password is not set, the database part fails as it can not access the database.
The logs on the shell are the following:
* bash[default :create initialize mysql database] action run[2015-01-16T10:03:03+00:00] INFO: Processing bash[default :create initialize mysql database] action run (/tmp/kitchen/cache/cookbooks/mysql/libraries/provider_mysql_service.rb line 143)
Installing MySQL system tables... 2015-01-16 10:03:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
OK
Filling help tables...
2015-01-16 10:03:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h default-centos-66.vagrantup.com password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
[2015-01-16T10:03:08+00:00] INFO: bash[default :create initialize mysql database] ran successfully
- execute "bash" "/tmp/chef-script20150116-2184-1tou5sq"
* bash[default :create initial records] action nothing[2015-01-16T10:03:08+00:00] INFO: Processing bash[default :create initial records] action nothing (/tmp/kitchen/cache/cookbooks/mysql/libraries/provider_mysql_service.rb line 152)
(skipped due to action :nothing)
[2015-01-16T10:03:08+00:00] INFO: bash[default :create initialize mysql database] sending run action to bash[default :create initial records] (delayed)
* bash[default :create initial records] action run[2015-01-16T10:03:08+00:00] INFO: Processing bash[default :create initial records] action run (/tmp/kitchen/cache/cookbooks/mysql/libraries/provider_mysql_service.rb line 152)
150116 10:03:08 mysqld_safe Logging to '/var/log/mysql-default/error.log'.
150116 10:03:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql-default
150116 10:03:12 mysqld_safe mysqld from pid file /var/run/mysql-default/mysqld.pid ended
[2015-01-16T10:03:12+00:00] INFO: bash[default :create initial records] ran successfully
- execute "bash" "/tmp/chef-script20150116-2184-gjywc9"
Anyone can bring some light why it is not setting that initial password?
Thanks in advance, -Enrique