chr4-cookbooks / mysqld Goto Github PK
View Code? Open in Web Editor NEWchef cookbook for installing and configuring mysql, only changing explicitly given options from the systems defaults
chef cookbook for installing and configuring mysql, only changing explicitly given options from the systems defaults
While coding the percona support, i have added a .kitchen.yml to verify the installations:
On ubuntu 16.04 found this:
run_list:
And set the root_password attribute:
But password is set on authentication string not on password field, i have accesed this mariadb but the password was not set, solved it using:
mysql --defaults-file=/etc/mysql/debian.cnf mysql -e "UPDATE user SET Password = PASSWORD('abcdef01234567890') WHERE User = 'root'; FLUSH PRIVILEGES;"
I dont know if this happened because using the mariadb.org repository.
I'm trying to use this cookbook with Vagrant, but I can't get it to allow the MySQL user root
to have no password. I added cookbook "mysqld"
to my Cheffile
, and the following to my Vagrantfile
:
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "mysqld"
end
But when I do vagrant up
, the Chef configuration fails. Here is the relevant output:
==> default: ================================================================================
==> default: Recipe Compile Error in /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/default.rb
==> default: ================================================================================
==> default:
==> default:
==> default: Chef::Exceptions::ValidationFailed
==> default: ----------------------------------
==> default: Required argument password is missing!
==> default:
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default: /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/configure.rb:26:in `block in from_file'
==> default:
==> default: /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/configure.rb:25:in `from_file'
==> default:
==> default: /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/default.rb:22:in `from_file'
==> default:
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/configure.rb:
==> default:
==> default: 19: #
==> default: 20:
==> default: 21: # Configure mysql/mariadb according to attributes
==> default: 22: mysqld 'default'
==> default: 23:
==> default: 24: # Set password according to attribute, if set
==> default: 25: mysqld_password 'root' do
==> default: 26>> password node['mysqld']['root_password']
==> default: 27: only_if { node['mysqld']['root_password'] }
==> default: 28: end
==> default: 29:
==> default: 30: # Set debian-sys-maint password on Debian family
==> default: 31: mysqld_password 'debian-sys-maint' do
==> default: 32: password node['mysqld']['root_password']
==> default: 33: only_if { node['mysqld']['root_password'] && node['platform_family'] == 'debian' }
==> default: 34: end
==> default: 35:
==> default:
==> default: [2015-03-26T21:29:12+00:00] ERROR: Running exception handlers
==> default: [2015-03-26T21:29:12+00:00] ERROR: Exception handlers complete
==> default: [2015-03-26T21:29:12+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2015-03-26T21:29:12+00:00] ERROR: Required argument password is missing!
The documentation mentions that the root password will be set if given, so I don't see why the argument is required.
Any thoughts?
When using the default mysql (At this time 5.5.52 on debian 8) password doesn't get updated and mysql root user remains without password.
Updating authentication_string has no effect on this version. Searching over the web found the following:
MySQL 5.7.5 and earlier version:
SET PASSWORD FOR 'user_name' = PASSWORD('new_password');
MySQL 5.7.6 and later version:
alter user 'user_name' identified by 'new_password';
Also, the execution of the query fails with a "no database selected". fixed on a copy of the cookbook locally, but also the authentication_string also was of no effect to change the password.
When trying to use this cookbook and changing the node.default['mysqld']['service_name'] value, I get the following error
==> db: ================================================================================
==> db: Error executing actionrestart
on resource 'service[mysql]'
==> db: ================================================================================
==> db:
==> db: Mixlib::ShellOut::ShellCommandFailed
==> db: ------------------------------------
==> db: Expected process to exit with [0], but received '5'
==> db: ---- Begin output of /bin/systemctl restart mysql ----
==> db: STDOUT:
==> db: STDERR: Failed to restart mysql.service: Unit not found.
==> db: ---- End output of /bin/systemctl restart mysql ----
==> db: Ran /bin/systemctl restart mysql returned 5
==> db:
==> db: Resource Declaration:
==> db: ---------------------
==> db: # In /tmp/vagrant-chef/824d535e25710db30ed17d906f18aa01/cookbooks/mysqld/providers/default.rb
==> db:
==> db: 48: service new_resource.service_name do
==> db: 49: # Use --wsrep-new-cluster if this is an initial galera startup
==> db: 50: if new_resource.galera_init
==> db: 51: start_command "service #{new_resource.service_name} start --wsrep-new-cluster --wsrep_cluster_address=gcomm://"
==> db: 52: end
==> db: 53:
==> db:
==> db: Compiled Resource:
==> db: ------------------
==> db: # Declared in /tmp/vagrant-chef/824d535e25710db30ed17d906f18aa01/cookbooks/mysqld/providers/default.rb:48:in `block in class_from_file'
==> db:
==> db: service("mysql") do
==> db: action [:enable, :start]
==> db: supports {:restart=>nil, :reload=>nil, :status=>nil}
==> db: retries 0
==> db: retry_delay 2
==> db: default_guard_interpreter :default
==> db: service_name "mysql"
==> db: pattern "mysql"
==> db: declared_type :service
==> db: cookbook_name :mysqld
==> db: not_if { #code block }
==> db: end
It looks as though the service name is still "mysql" instead of the value I pass through as node.default['mysqld']['service_name'] - in this instance, "mysqld"
Description
In Chef Client 13 some types of resource properties became immutable, including Hash.
create
on resource 'mysqld[default]' RuntimeError
------------
can't modify frozen Hash
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/mysqld/providers/default.rb:23:in `block in class_from_file'
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/mysqld/recipes/configure.rb
22: mysqld 'default'
23:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/mysqld/recipes/configure.rb:22:in `from_file'
mysqld("default") do
action [:create]
default_guard_interpreter :default
declared_type :mysqld
cookbook_name "mysqld"
recipe_name "configure"
end
System Info:
------------
chef_version=13.2.20
platform=ubuntu
platform_version=16.04
ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
program_name=chef-client worker: ppid=1615;start=13:23:26;
executable=/opt/chef/bin/chef-client
If it's interesting, i can make a pull request with support for percona, like mariadb.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.