-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add percona support, add kitchen and tests with serverspec #14
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull-request! Aside from the small change requests, this looks good to me!
providers/password.rb
Outdated
@@ -21,7 +21,7 @@ | |||
|
|||
action :set do | |||
r = execute "Assign mysql password for #{new_resource.user} user" do | |||
query = "UPDATE user SET authentication_string = PASSWORD('#{Shellwords.escape(new_resource.password)}') WHERE User = '#{Shellwords.escape(new_resource.user)}'" | |||
query = "UPDATE user SET #{node['mysqld']['pwd_col']} = PASSWORD('#{Shellwords.escape(new_resource.password)}') WHERE User = '#{Shellwords.escape(new_resource.user)}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Shellwords.escape()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
attributes/defaults.rb
Outdated
default['mysqld']['pwd_col'] = 'authentication_string' | ||
end | ||
else | ||
default['mysqld']['pwd_col'] = 'authentication_string' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the else
really required? Unless mariadb
, percona
or mysql
was set, we're going to have some trouble later on anyway, won't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, will cleanup an commit again.
attributes/defaults.rb
Outdated
default['mysqld']['pwd_col'] = 'authentication_string' | ||
end | ||
when 'mysql' | ||
if node['platform'] == 'debian' && node['platform_version'].to_f < 9.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we should add an attribute node['mysqld']['mysql']['version']
analogue to the percona configuration and check for the version instead of node['platform_version']
. The version attribute can then be defaulted for a specific platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds better, this was only to use the right column when setting the password and using default distro packages, in this case, debian jessie comes with mysql 5.5, and stretch at the moment with 5.6 which i believe will end having 5.7 which support authentication_string.
Using chef_sugar maybe does it make it more readable, but adds a dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the changes proposed above, I was thinking about something like this:
case node['mysqld']['db_install']
when 'mariadb'
default['mysqld']['pwd_col'] = 'Password'
when 'percona'
if node['mysqld']['percona']['version'] < 5.7
default['mysqld']['pwd_col'] = 'Password'
else
default['mysqld']['pwd_col'] = 'authentication_string'
end
when 'mysql'
if node['mysqld']['mysql']['version'] < 5.7
default['mysqld']['pwd_col'] = 'Password'
else
default['mysqld']['pwd_col'] = 'authentication_string'
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then have something like this ?
if node['platform'] == 'debian' && node['platform_version'].to_i < 10
# At this time, stretch still uses mysql 5.6
default['mysqld']['mysql']['version'] = 5.6
elsif node['platform'] == 'ubuntu' && node['platform_version'].to_f < 16.04
default['mysqld']['mysql']['version'] = 5.6
else
default['mysqld']['mysql']['version'] = 5.7
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running kitchen tests right now, if everything goes smoothly will commit this change.
attributes/defaults.rb
Outdated
default['mysqld']['repository']['percona']['mirror'] = 'http://repo.percona.com/apt' | ||
|
||
if node['mysqld']['repository']['percona']['version'] == '5.7' | ||
default['mysqld']['percona_packages'] = %w(percona-server-server-5.7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest moving the package attributes percona_packages
mariadb_packages
and mariadb_galera_packages
into a sub-attribute, like: default['mysqld']['mariadb']['packages']
. Then we'd have all the repository-related configuration in one hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine, this change its better, but also will move attributes of repositories to that hierarchy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also migrate the repository attributes to be consistent with the new hierarchy:
default['mysqld']['mariadb']['version'] = 10.1 # We shouldn't use a string here, I suppose
default['mysqld']['mariadb']['repository'] = 'http://ftp.hosteurope.de/mirror/mariadb.org/repo'
The version
attribute can then be used later to determine the correct pwd_col
.
All requested changes have been commited but the one about using platform_version. |
Everything went ok. Any other suggestions ? |
I've just encountered a problem, and I don't have a simple/ clean solution for it. When releasing I'm sorry to find this out after you fixed some issues, but I think that best for maintenance is to only support recent mysql/ mariadb/ percona versions that actually use Would that still work for you? |
Mysql 5.7 but lower than 5.7.6 is not found unless installed by hand specifically on the repositories affected. The changes introduced bring support to avoid version locking the cookbook to 1.0.5 since the problem was basically the authentication_string column. |
In percona apt repository, you can't find something lower than 5.7.11. On Debian jessie you will find 5.5, and there is no way to install 5.7 automatically using this recipe. At this time, stretch which is debian 9.0 has mysql 5.6 at this time, unless it's updated with sid packages, then it will upgrade to 5.7.15, so no issues other than changing the mysql-server version supported on this distro. I don't think this will be an issue in the foreseeable future. |
So you'd say even though the check for I think there's more to it. When I was adding support for While it is surely possible to adjust them manually, my advise to users of Debian therefore would be to use MariaDB from the provided repositories. Databases are often used for critical data, and I personally what to have safe defaults for the supported versions. I'm aware, that this leaves Debian users that don't want to use third-party repositories (or don't want MariaDB) out, but I think this is the best compromise currently. |
Ok, but that it's another issue, not the thing addressed because mysql was <5.7.6 and the Password was stored on Password field and not authentication_string. Those can be addapted to handle 5.6 changes. But afaik when you run the tests with kitchen the database starts and works. Therefore i dont see it causing any issues. |
Here's my suggestion: We split this pull-request up into two:
Then we can discuss pros and cons for backwards compatibility seperately. Sounds good? |
+1 |
How would you like to do this ? close this pull request and open 2 separate ones ? |
Whatever is easiest for you. You can also remove the 5.6 part and force-push if this is more convenient. |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the README, this looks good to me!
# Attribute that defines whether MariaDB or MySQL should be used | ||
default['mysqld']['use_mariadb'] = true | ||
# Attribute that defines whether MariaDB, MySQL or Percona should be used | ||
default['mysqld']['db_install'] = 'mariadb' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing missing now is a note in the README explaining the use of the db_install
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im seeing right now, the repository configuration must be included inside install to avoid asking the user to include the repository configuration, with percona this is necessary but i have my doubts with mariadb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate? I'm not sure what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
Percona 5.6 is included on ubuntu 16.04, but it will work since we require mysql 5.7 at least. So, include_recipe 'mysqld::percona_repository'
needs to be included, but its a hassle since you already configured an attribute to use percona.
The same happens with mariadb, to ensure the version we want, we must include mariadb.org repositories to avoid this failing if you select version 10.2 and using default xenial repositories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah i understand. Vor MariaDB, this is solved as the default recipe includes the apt_repository recipe, too. So, while you can use the cookbook without the apt repository, the default "just works". For percona, you're right. One option would be to just leave it as it is (and add a warning to the README), or automatically include the apt_repository in the install recipe when percona is selected in the attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated docs and forced mysqld::percona_repository when installing percona.
recipes/install.rb
Outdated
@@ -26,6 +26,7 @@ | |||
when 'mariadb' | |||
Array(node['mysqld']['mariadb']['packages']).each { |pkg| package pkg } | |||
when 'percona' | |||
include_recipe 'mysqld::percona_repository' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment explaining why the repository is set up would be nice for the future. Especially since we're not doing it for mariadb.
recipes/install.rb
Outdated
@@ -26,6 +26,7 @@ | |||
when 'mariadb' | |||
Array(node['mysqld']['mariadb']['packages']).each { |pkg| package pkg } | |||
when 'percona' | |||
# This is included here, since percona 5.7 is not included in any of the distros supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! My suggestion to make it a little more clear:
Always use the official percona repository, as some distributions use percona-5.6, and the default attributes of this cookbook require 5.7
recipes/install.rb
Outdated
@@ -26,6 +26,7 @@ | |||
when 'mariadb' | |||
Array(node['mysqld']['mariadb']['packages']).each { |pkg| package pkg } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike with percona, the apt repository for mariadb is not automatically set up in this recipe. While the default recipe makes sure the repository is used, not including it here makes it possible to use distribution packages of mariadb. This is a little dangerous, as the cookbook officially only supports mysql-5.7 and mariadb-10.1
I'm not sure whether it might be a good idea to include the apt repository here, too.
But as there's no check whether mysql-5.7 is used, we might leave this up to the user. I'm a little concernded when it's possible to easily install a non-supported database version that might lead into problems. Thoughts on this?
…ate pull request chr4-cookbooks/pull/13 with some changes to include percona and versions of databases. Use cookstyle instead of rubocop. (https://github.com/chef/cookstyle)
Thoughts on whether to automatically include the mariadb repository in the As The issue is a little smaller, as the Thoughts on this? |
@@ -18,9 +18,18 @@ | |||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
# | |||
|
|||
# This way we force to have updated indexes | |||
include_recipe 'apt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required? apt-get update
should be run automatically when adding the repository below.
@@ -54,6 +60,14 @@ | |||
default['mysqld']['my.cnf']['mysqld_safe']['skip_log_error'] = true | |||
end | |||
|
|||
# Password columns for user passwords | |||
default['mysqld']['pwd_col'] = case node['mysqld']['db_install'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to document the pwd_col
attribute in the README? It could be overridden using override['mysqld']['pwd_col']
if necessary.
It might be a good idea to keep this internal, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in order to hide this from the user completely, we could remove the attribute and move the decision for the proper pwd_col to the the password provider.
I think the user doesn't need to be able to change which column is actually used.
edit: Would it be possible to use the SET PASSWORD
statement instead?
mariadb
mysql
edit2: I just noticed the deprecation notice for the statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An attribute won't hurt, and opens up the option for advanced users to use this cookbook with older mysql versions.
The only concern I have is, that the cookbook advises and deploys defaults that are unsafe, not sane, etc. I'm not sure howto "enforce" this (or whether it's a good idea to do so), besides a warning in the README.
Add percona support, add kitchen and tests with serverspec and integrate pull request /pull/13 with some changes to include percona and versions of databases.