diff --git a/.fixtures.yml b/.fixtures.yml index a27ae9b8e..5c67151b0 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -6,4 +6,4 @@ fixtures: "provision": "https://github.com/puppetlabs/provision.git" puppet_agent: repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - ref: v4.13.0 + ref: v4.21.0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d80c53ed..92a1410b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: - name: Setup Acceptance Test Matrix id: get-matrix run: | - bundle exec matrix_from_metadata_v2 --exclude-platforms '["Ubuntu-22.04-arm", "RedHat-9-arm"]' + bundle exec matrix_from_metadata_v2 --exclude-platforms '["Debian-12-arm", "Ubuntu-22.04-arm", "RedHat-9-arm"]' Acceptance: name: "${{matrix.platforms.label}}, ${{matrix.collection}}" diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml deleted file mode 100644 index 0d4870d70..000000000 --- a/.github/workflows/labeller.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Labeller - -on: - issues: - types: - - opened - - labeled - - unlabeled - pull_request: - types: - - opened - - labeled - - unlabeled - -jobs: - label: - runs-on: ubuntu-latest - steps: - - - uses: puppetlabs/community-labeller@v1.0.1 - name: Label issues or pull requests - with: - label_name: community - label_color: '5319e7' - org_membership: puppetlabs - fail_if_member: 'true' - token: ${{ secrets.IAC_COMMUNITY_LABELER }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f14093117..795a46372 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -38,7 +38,7 @@ jobs: - name: Setup Acceptance Test Matrix id: get-matrix run: | - bundle exec matrix_from_metadata_v2 --exclude-platforms '["Ubuntu-22.04-arm", "RedHat-9-arm"]' + bundle exec matrix_from_metadata_v2 --exclude-platforms '["Debian-12-arm", "Ubuntu-22.04-arm", "RedHat-9-arm"]' Acceptance: name: "${{matrix.platforms.label}}, ${{matrix.collection}}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b7b8a05d..4b3b80fc8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: "Publish module" on: workflow_dispatch: - + jobs: release: uses: "puppetlabs/cat-github-actions/.github/workflows/module_release.yml@main" diff --git a/.gitignore b/.gitignore index 3f1551212..2803e566b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,3 +27,9 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log diff --git a/.pdkignore b/.pdkignore index 862847a72..84684be63 100644 --- a/.pdkignore +++ b/.pdkignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,6 +27,12 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log /.fixtures.yml /Gemfile /.gitattributes diff --git a/.rubocop.yml b/.rubocop.yml index 70ff105a8..1b2b97111 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,13 +1,12 @@ --- inherit_from: .rubocop_todo.yml - require: - rubocop-performance - rubocop-rspec AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.7' + TargetRubyVersion: '2.6' Include: - "**/*.rb" Exclude: @@ -530,6 +529,8 @@ Lint/DuplicateBranch: Enabled: false Lint/DuplicateMagicComment: Enabled: false +Lint/DuplicateMatchPattern: + Enabled: false Lint/DuplicateRegexpCharacterClassElement: Enabled: false Lint/EmptyBlock: @@ -646,6 +647,8 @@ Style/ComparableClamp: Enabled: false Style/ConcatArrayLiterals: Enabled: false +Style/DataInheritance: + Enabled: false Style/DirEmpty: Enabled: false Style/DocumentDynamicEvalDefinition: @@ -714,6 +717,8 @@ Style/RedundantHeredocDelimiterQuotes: Enabled: false Style/RedundantInitialize: Enabled: false +Style/RedundantLineContinuation: + Enabled: false Style/RedundantSelfAssignmentBranch: Enabled: false Style/RedundantStringEscape: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 2f1e4f73a..6da8d472f 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,6 @@ { "recommendations": [ "puppet.puppet-vscode", - "rebornix.Ruby" + "Shopify.ruby-lsp" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index f67cae79f..f90f52695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +## [v16.2.0](https://github.com/puppetlabs/puppetlabs-mysql/tree/v16.2.0) - 2024-12-16 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-mysql/compare/v16.1.0...v16.2.0) + +## [v16.1.0](https://github.com/puppetlabs/puppetlabs-mysql/tree/v16.1.0) - 2024-12-09 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-mysql/compare/v16.0.0...v16.1.0) + +### Added + +- (CAT-2100) Add Debian 12 support [#1653](https://github.com/puppetlabs/puppetlabs-mysql/pull/1653) ([shubhamshinde360](https://github.com/shubhamshinde360)) + +### Fixed + +- (CAT-2158) Upgrade rexml to address CVE-2024-49761 [#1656](https://github.com/puppetlabs/puppetlabs-mysql/pull/1656) ([amitkarsale](https://github.com/amitkarsale)) +- Fix backup/rotation with multiple excluded databases [#1610](https://github.com/puppetlabs/puppetlabs-mysql/pull/1610) ([BuJo](https://github.com/BuJo)) + ## [v16.0.0](https://github.com/puppetlabs/puppetlabs-mysql/tree/v16.0.0) - 2024-07-11 [Full Changelog](https://github.com/puppetlabs/puppetlabs-mysql/compare/v15.0.0...v16.0.0) @@ -842,7 +859,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ### Fixed - PR 654 was incorrectly using stdlib dirname [#677](https://github.com/puppetlabs/puppetlabs-mysql/pull/677) ([underscorgan](https://github.com/underscorgan)) -- Fix bug in 578 [#671](https://github.com/puppetlabs/puppetlabs-mysql/pull/671) ([aldavud](https://github.com/aldavud)) +- Fix bug in 578 [#671](https://github.com/puppetlabs/puppetlabs-mysql/pull/671) ([](https://github.com/)) - Check for full path for log-bin to stop puppet from managing directory “." [#654](https://github.com/puppetlabs/puppetlabs-mysql/pull/654) ([NoodlesNZ](https://github.com/NoodlesNZ)) ## [3.2.0](https://github.com/puppetlabs/puppetlabs-mysql/tree/3.2.0) - 2015-02-10 diff --git a/Gemfile b/Gemfile index ca0e773ec..2d8e1608b 100644 --- a/Gemfile +++ b/Gemfile @@ -20,30 +20,30 @@ group :development do gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "deep_merge", '~> 1.2.2', require: false gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false - gem "facterdb", '~> 1.18', require: false - gem "metadata-json-lint", '~> 3.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false - gem "rspec-puppet-facts", '~> 2.0', require: false - gem "codecov", '~> 0.2', require: false + gem "facterdb", '~> 2.1', require: false + gem "metadata-json-lint", '~> 4.0', require: false + gem "rspec-puppet-facts", '~> 4.0', require: false gem "dependency_checker", '~> 1.0.0', require: false gem "parallel_tests", '= 3.12.1', require: false gem "pry", '~> 0.10', require: false - gem "simplecov-console", '~> 0.5', require: false + gem "simplecov-console", '~> 0.9', require: false gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.48.1', require: false + gem "rubocop", '~> 1.50.0', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false - gem "puppet-strings", '~> 4.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "rexml", '>= 3.3.9', require: false end -group :system_tests do - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] - gem "serverspec", '~> 2.41', require: false -end -group :release_prep do +group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false + gem "puppetlabs_spec_helper", '~> 7.0', require: false +end +group :system_tests do + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "serverspec", '~> 2.41', require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/lib/puppet/provider/mysql.rb b/lib/puppet/provider/mysql.rb index 192bb92e8..cc66ccbfb 100644 --- a/lib/puppet/provider/mysql.rb +++ b/lib/puppet/provider/mysql.rb @@ -38,29 +38,17 @@ class Puppet::Provider::Mysql < Puppet::Provider ].join(':') # rubocop:disable Style/HashSyntax - commands :mysql_client => 'mysql' + commands :mysql_client => 'mariadb' commands :mariadb_client => 'mariadb' - commands :mysqld_service => 'mysqld' + commands :mysqld_service => 'mariadbd' commands :mariadbd_service => 'mariadbd' - commands :mysql_admin => 'mysqladmin' + commands :mysql_admin => 'mariadbadmin' commands :mariadb_admin => 'mariadb-admin' + commands :mysql_raw => 'mariadb' + commands :mysqld => 'mariadbd' + commands :mysqladmin => 'mariadbadmin' # rubocop:enable Style/HashSyntax - def self.mysql_raw(*args) - mysqld_version_string.scan(%r{mariadb}i) { return mariadb_client(*args) } - mysql_client(*args) - end - - def self.mysqld(*args) - mysqld_version_string.scan(%r{mariadb}i) { return mariadbd_service(*args) } - mysqld_service(*args) - end - - def self.mysqladmin(*args) - mysqld_version_string.scan(%r{mariadb}i) { return mariadb_admin(*args) } - mysql_admin(*args) - end - # Optional defaults file def self.defaults_file "--defaults-extra-file=#{Facter.value(:root_home)}/.my.cnf" if File.file?("#{Facter.value(:root_home)}/.my.cnf") diff --git a/lib/puppet/provider/mysql_database/mysql.rb b/lib/puppet/provider/mysql_database/mysql.rb index 04d95bf76..49d4de523 100644 --- a/lib/puppet/provider/mysql_database/mysql.rb +++ b/lib/puppet/provider/mysql_database/mysql.rb @@ -4,7 +4,7 @@ Puppet::Type.type(:mysql_database).provide(:mysql, parent: Puppet::Provider::Mysql) do desc 'Manages MySQL databases.' - commands mysql_raw: 'mysql' + commands mysql_raw: 'mariadb' def self.instances mysql_caller('show databases', 'regular').split("\n").map do |name| diff --git a/lib/puppet/provider/mysql_datadir/mysql.rb b/lib/puppet/provider/mysql_datadir/mysql.rb index 08d6bfa14..897d17966 100644 --- a/lib/puppet/provider/mysql_datadir/mysql.rb +++ b/lib/puppet/provider/mysql_datadir/mysql.rb @@ -34,7 +34,7 @@ '/usr/mysql/5.7/bin', ].join(':') - commands mysqld: 'mysqld' + commands mysqld: 'mariadbd' optional_commands mysql_install_db: 'mysql_install_db' # rubocop:disable Lint/UselessAssignment def create diff --git a/lib/puppet/provider/mysql_grant/mysql.rb b/lib/puppet/provider/mysql_grant/mysql.rb index 20af17151..3308835e4 100644 --- a/lib/puppet/provider/mysql_grant/mysql.rb +++ b/lib/puppet/provider/mysql_grant/mysql.rb @@ -4,7 +4,7 @@ Puppet::Type.type(:mysql_grant).provide(:mysql, parent: Puppet::Provider::Mysql) do desc 'Set grants for users in MySQL.' - commands mysql_raw: 'mysql' + commands mysql_raw: 'mariadb' def self.instances instance_configs = {} diff --git a/lib/puppet/provider/mysql_plugin/mysql.rb b/lib/puppet/provider/mysql_plugin/mysql.rb index 82db9f941..8e6e492cc 100644 --- a/lib/puppet/provider/mysql_plugin/mysql.rb +++ b/lib/puppet/provider/mysql_plugin/mysql.rb @@ -4,7 +4,7 @@ Puppet::Type.type(:mysql_plugin).provide(:mysql, parent: Puppet::Provider::Mysql) do desc 'Manages MySQL plugins.' - commands mysql_raw: 'mysql' + commands mysql_raw: 'mariadb' def self.instances mysql_caller('show plugins', 'regular').split("\n").map do |line| diff --git a/lib/puppet/provider/mysql_user/mysql.rb b/lib/puppet/provider/mysql_user/mysql.rb index a381d6898..1e1f3d2ea 100644 --- a/lib/puppet/provider/mysql_user/mysql.rb +++ b/lib/puppet/provider/mysql_user/mysql.rb @@ -3,12 +3,13 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) Puppet::Type.type(:mysql_user).provide(:mysql, parent: Puppet::Provider::Mysql) do desc 'manage users for a mysql database.' - commands mysql_raw: 'mysql' + commands mysql_raw: 'mariadb' # Build a property_hash containing all the discovered information about MySQL # users. def self.instances - users = mysql_caller("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').split("\n") + users = mysql_caller("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user where HOST IS NOT NULL AND HOST != ''", 'regular').split("\n") + # users = users_full.reject { |user| user == 'PUBLIC@' } # To reduce the number of calls to MySQL we collect all the properties in # one big swoop. users.map do |name| diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp index c73831f38..1cf6910bb 100644 --- a/manifests/backup/xtrabackup.pp +++ b/manifests/backup/xtrabackup.pp @@ -86,7 +86,7 @@ } } else { - if $facts['os']['family'] == 'debian' and $facts['os']['release']['major'] == '11' or + if ($facts['os']['name'] == 'debian' and versioncmp($facts['os']['release']['major'], '11') >= 0) or ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '22.04') >= 0) { mysql_grant { "${backupuser}@localhost/*.*": ensure => $ensure, diff --git a/manifests/params.pp b/manifests/params.pp index c547fe8c2..6c2e6be25 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -61,7 +61,7 @@ } } default: { - $provider = 'mysql' + $provider = 'mariadb' } } @@ -217,6 +217,7 @@ '9' => 'ruby-mysql2', # stretch '10' => 'ruby-mysql2', # buster '11' => 'ruby-mysql2', # bullseye + '12' => 'ruby-mysql2', # bookworm '16.04' => 'ruby-mysql', # xenial '18.04' => 'ruby-mysql2', # bionic '20.04' => 'ruby-mysql2', # focal diff --git a/manifests/server/installdb.pp b/manifests/server/installdb.pp index 04df65a9a..b62d1e804 100644 --- a/manifests/server/installdb.pp +++ b/manifests/server/installdb.pp @@ -13,6 +13,7 @@ $basedir = $mysql::server::_options['mysqld']['basedir'] $config_file = $mysql::server::config_file $log_error = $mysql::server::_options['mysqld']['log-error'] + $log_dir = '/var/log/mysql' if $mysql::server::manage_config_file and $config_file != $mysql::params::config_file { $_config_file=$config_file @@ -30,6 +31,12 @@ } } + file { $log_dir: + ensure => 'directory', + owner => $mysqluser, + group => $mysql::server::mysql_group, + } + mysql_datadir { $datadir: ensure => 'present', datadir => $datadir, diff --git a/metadata.json b/metadata.json index dbc997644..65ee44dcd 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-mysql", - "version": "16.0.0", + "version": "16.2.0", "author": "puppetlabs", "summary": "Installs, configures, and manages the MySQL service.", "license": "Apache-2.0", @@ -39,7 +39,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "10", - "11" + "11", + "12" ] }, { @@ -84,6 +85,6 @@ ], "description": "MySQL module", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "heads/main-0-g79a2f93", - "pdk-version": "3.0.0" + "template-ref": "tags/3.2.0.4-0-g5d17ec1", + "pdk-version": "3.2.0" } diff --git a/spec/classes/mysql_backup_mysqldump_spec.rb b/spec/classes/mysql_backup_mysqldump_spec.rb index 6389e580a..b44c2b7ce 100644 --- a/spec/classes/mysql_backup_mysqldump_spec.rb +++ b/spec/classes/mysql_backup_mysqldump_spec.rb @@ -76,13 +76,13 @@ class { 'mysql::server': } let(:params) do { 'file_per_database' => true, - 'excludedatabases' => ['information_schema'] + 'excludedatabases' => ['information_schema', 'performance_schema'] }.merge(default_params) end it { expect(subject).to contain_file('mysqlbackup.sh').with_content( - %r{information_schema}, + %r{information_schema\\\|performance_schema}, ) } end diff --git a/spec/classes/mysql_server_spec.rb b/spec/classes/mysql_server_spec.rb index 3ff307b71..1ac1eace1 100644 --- a/spec/classes/mysql_server_spec.rb +++ b/spec/classes/mysql_server_spec.rb @@ -279,7 +279,7 @@ expect(subject).to contain_mysql_user('foo@localhost').with( max_connections_per_hour: '1', max_queries_per_hour: '2', max_updates_per_hour: '3', max_user_connections: '4', - password_hash: 'Sensitive [value redacted]' + password_hash: sensitive('*F3A2A51A9B0F2BE2468926B4132313728C250DBF') ) } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4d7abc00f..43c522e28 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,7 +25,8 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + require 'deep_merge' + default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end @@ -33,7 +34,7 @@ # read default_facts and merge them over what is provided by facterdb default_facts.each do |fact, value| - add_custom_fact fact, value + add_custom_fact fact, value, merge_facts: true end RSpec.configure do |c| diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index 5cad805a4..33f6da341 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -36,8 +36,12 @@ def sles_15? os[:family] == 'sles' && os[:release].to_i == 15 end +def debian_12? + os[:family] == 'debian' && os[:release].to_i == 12 +end + def charset - @charset ||= (ubuntu_2204? || sles_15?) ? 'utf8mb3' : 'utf8' + @charset ||= (debian_12? || ubuntu_2204? || sles_15?) ? 'utf8mb3' : 'utf8' end RSpec.configure do |c| diff --git a/spec/unit/facter/mysql_server_id_spec.rb b/spec/unit/facter/mysql_server_id_spec.rb index fb914a9d4..00f20013e 100644 --- a/spec/unit/facter/mysql_server_id_spec.rb +++ b/spec/unit/facter/mysql_server_id_spec.rb @@ -10,7 +10,7 @@ describe 'mysql_server_id' do context "igalic's laptop" do before :each do - allow(Facter.fact(:macaddress)).to receive(:value).and_return('3c:97:0e:69:fb:e1') + allow(Facter).to receive(:value).with(:macaddress).and_return('3c:97:0e:69:fb:e1') end it do @@ -20,7 +20,7 @@ context 'node with lo only' do before :each do - allow(Facter.fact(:macaddress)).to receive(:value).and_return('00:00:00:00:00:00') + allow(Facter).to receive(:value).with(:macaddress).and_return('00:00:00:00:00:00') end it do @@ -30,7 +30,7 @@ context 'test nil case' do before :each do - allow(Facter.fact(:macaddress)).to receive(:value).and_return(nil) + allow(Facter).to receive(:value).with(:macaddress).and_return(nil) end it do diff --git a/spec/unit/puppet/provider/mysql_user/mysql_spec.rb b/spec/unit/puppet/provider/mysql_user/mysql_spec.rb index 6a900f8ae..2617e256c 100644 --- a/spec/unit/puppet/provider/mysql_user/mysql_spec.rb +++ b/spec/unit/puppet/provider/mysql_user/mysql_spec.rb @@ -101,14 +101,14 @@ allow(Puppet::Util).to receive(:which).with('mysql').and_return('/usr/bin/mysql') allow(Puppet::Util).to receive(:which).with('mysqld').and_return('/usr/sbin/mysqld') allow(File).to receive(:file?).with('/root/.my.cnf').and_return(true) - allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').and_return('joe@localhost') + allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user where HOST IS NOT NULL AND HOST != ''", 'regular').and_return('joe@localhost') allow(provider.class).to receive(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = 'joe@localhost'", 'regular').and_return('10 10 10 10 *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4') # rubocop:disable Layout/LineLength end describe 'self.instances' do it 'returns an array of users MySQL 5.5' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.5'][:string]) - allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').and_return(raw_users) + allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user where HOST IS NOT NULL AND HOST != ''", 'regular').and_return(raw_users) parsed_users.each { |user| allow(provider.class).to receive(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').and_return('10 10 10 10 ') } # rubocop:disable Layout/LineLength usernames = provider.class.instances.map(&:name) @@ -117,7 +117,7 @@ it 'returns an array of users MySQL 5.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.6'][:string]) - allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').and_return(raw_users) + allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user where HOST IS NOT NULL AND HOST != ''", 'regular').and_return(raw_users) parsed_users.each { |user| allow(provider.class).to receive(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').and_return('10 10 10 10 ') } # rubocop:disable Layout/LineLength usernames = provider.class.instances.map(&:name) @@ -126,7 +126,7 @@ it 'returns an array of users MySQL >= 5.7.0 < 5.7.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string]) - allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').and_return(raw_users) + allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user where HOST IS NOT NULL AND HOST != ''", 'regular').and_return(raw_users) parsed_users.each { |user| allow(provider.class).to receive(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').and_return('10 10 10 10 ') } # rubocop:disable Layout/LineLength usernames = provider.class.instances.map(&:name) @@ -135,7 +135,7 @@ it 'returns an array of users MySQL >= 5.7.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string]) - allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').and_return(raw_users) + allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user where HOST IS NOT NULL AND HOST != ''", 'regular').and_return(raw_users) parsed_users.each { |user| allow(provider.class).to receive(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, AUTHENTICATION_STRING, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').and_return('10 10 10 10 ') } # rubocop:disable Layout/LineLength usernames = provider.class.instances.map(&:name) @@ -144,7 +144,7 @@ it 'returns an array of users mariadb 10.0' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mariadb-10.0'][:string]) - allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').and_return(raw_users) + allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user where HOST IS NOT NULL AND HOST != ''", 'regular').and_return(raw_users) parsed_users.each { |user| allow(provider.class).to receive(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').and_return('10 10 10 10 ') } # rubocop:disable Layout/LineLength usernames = provider.class.instances.map(&:name) @@ -153,7 +153,7 @@ it 'returns an array of users mariadb >= 10.1.21' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mariadb-10.1.44'][:string]) - allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').and_return(raw_users) + allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user where HOST IS NOT NULL AND HOST != ''", 'regular').and_return(raw_users) parsed_users.each { |user| allow(provider.class).to receive(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD, PLUGIN, AUTHENTICATION_STRING FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').and_return('10 10 10 10 ') } # rubocop:disable Layout/LineLength usernames = provider.class.instances.map(&:name) @@ -162,7 +162,7 @@ it 'returns an array of users percona 5.5' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['percona-5.5'][:string]) - allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').and_return(raw_users) + allow(provider.class).to receive(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user where HOST IS NOT NULL AND HOST != ''", 'regular').and_return(raw_users) parsed_users.each { |user| allow(provider.class).to receive(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').and_return('10 10 10 10 ') } # rubocop:disable Layout/LineLength usernames = provider.class.instances.map(&:name) diff --git a/templates/mysqlbackup.sh.epp b/templates/mysqlbackup.sh.epp index f1301043b..3111296c3 100644 --- a/templates/mysqlbackup.sh.epp +++ b/templates/mysqlbackup.sh.epp @@ -84,7 +84,7 @@ cleanup <% if $excludedatabases.empty { -%> mysql --defaults-extra-file=$TMPFILE -s -r -N -e 'SHOW DATABASES' | while read dbname <%} else {-%> -mysql --defaults-extra-file=$TMPFILE -s -r -N -e 'SHOW DATABASES' | grep -v '^\(<%= $excludedatabases.join('|') %>\)$' | while read dbname +mysql --defaults-extra-file=$TMPFILE -s -r -N -e 'SHOW DATABASES' | grep -v '^\(<%= $excludedatabases.join('\\|') %>\)$' | while read dbname <% } -%> do <%= $backupmethod %> --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \