From 82110477e421c1db740194869cfc80c6f32ad66d Mon Sep 17 00:00:00 2001 From: rajat-puppet Date: Mon, 22 Jul 2024 17:31:19 +0530 Subject: [PATCH 01/12] Remove labeller.yml --- .github/workflows/labeller.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/labeller.yml 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 }} From 5ef64e6250bb9d0b1c0ed7f473bfc2d3106e0e65 Mon Sep 17 00:00:00 2001 From: Marc Simonetti Date: Wed, 28 Aug 2024 16:26:11 +0200 Subject: [PATCH 02/12] Fix spec unit for mysql_server_id Value of the facter :macaddress was nil, causing tests to have two failures (contexts "igalic's laptop" and "node with lo only"). Update the facter initialization allows to pass the tests successfully. --- spec/unit/facter/mysql_server_id_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 From 118f33b5584700ec4a098f40ebeeebbbbca14f90 Mon Sep 17 00:00:00 2001 From: rahuls02997 Date: Wed, 18 Sep 2024 17:42:32 +0530 Subject: [PATCH 03/12] Fix mysql_users failing for SLES fix mistakes fix spec for the changed query --- lib/puppet/provider/mysql_user/mysql.rb | 3 ++- .../puppet/provider/mysql_user/mysql_spec.rb | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/puppet/provider/mysql_user/mysql.rb b/lib/puppet/provider/mysql_user/mysql.rb index a381d6898..b552a5620 100644 --- a/lib/puppet/provider/mysql_user/mysql.rb +++ b/lib/puppet/provider/mysql_user/mysql.rb @@ -8,7 +8,8 @@ # 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/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) From 7d90921b15c59c322a625e340f95595c5247e0e2 Mon Sep 17 00:00:00 2001 From: Jonathan Buch Date: Mon, 11 Dec 2023 10:56:11 +0100 Subject: [PATCH 04/12] Fix backup/rotation with multiple excluded databases * When using multiple excluded databases, the list of databases is filtered using `grep -v`. i.e. `grep -v '^\(information_schema|performance_schema\)$` * When using Basic vs Extended Regular Expressions, the characters `(` and `|` lose their special meaning, the backslashed versions have to be used. For the group (`()`) the escaping has been done, however the alternation is unescaped. Leading to: * All the excluded databases will be backed up. * In case a database is not backuppable (which is why it had been excluded), this leads to the cleanup not being run at all, as it depends on the backup having been successful. This MR aims to fix this issue, by revising the regular expression and specifying that behaviour in the respective class spec. --- spec/classes/mysql_backup_mysqldump_spec.rb | 4 ++-- templates/mysqlbackup.sh.epp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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 \ From 020fdea446c8c2402887cc2bc5d63ec323d5184f Mon Sep 17 00:00:00 2001 From: Amit Karsale Date: Tue, 1 Oct 2024 20:26:41 +0530 Subject: [PATCH 05/12] pdksync - (PF-3525) - pdk update for module --- .github/workflows/release.yml | 2 +- .gitignore | 7 +++++++ .pdkignore | 7 +++++++ .rubocop.yml | 9 +++++++-- .vscode/extensions.json | 2 +- Gemfile | 28 ++++++++++++++-------------- metadata.json | 4 ++-- spec/classes/mysql_server_spec.rb | 2 +- spec/spec_helper.rb | 5 +++-- 9 files changed, 43 insertions(+), 23 deletions(-) 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/Gemfile b/Gemfile index ca0e773ec..8e9f845e1 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.0.0', '< 3.2.7', 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/metadata.json b/metadata.json index dbc997644..1cac307e5 100644 --- a/metadata.json +++ b/metadata.json @@ -84,6 +84,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_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| From 074067abaa57f132d900b41e484cd8e9e3c4d662 Mon Sep 17 00:00:00 2001 From: Shubham Shinde Date: Fri, 18 Oct 2024 11:27:51 +0530 Subject: [PATCH 06/12] (CAT-2100) Add Debian 12 support - Add all Debian 11 and above platforms to have expected privileges. - Add ruby package for Debian 12 - When downloading the mariadb-server package '/var/log/mysql' is automatically created for other platforms, but that is not the case with Debian 12. So, make sure the directory is present. - Debian 12 uses utf8mb3 encoding since utf8 is not supported on it. - Skip Debian-12-arm platform from tests since the mysql binaries, 'my_print_defaults' and 'mysql_config_editor', are not supported for ARM architecture. --- .fixtures.yml | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/nightly.yml | 2 +- manifests/backup/xtrabackup.pp | 2 +- manifests/params.pp | 1 + manifests/server/installdb.pp | 7 +++++++ metadata.json | 3 ++- spec/spec_helper_acceptance_local.rb | 6 +++++- 8 files changed, 19 insertions(+), 6 deletions(-) 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/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/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..c53c4f6cd 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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 1cac307e5..e7234e88f 100644 --- a/metadata.json +++ b/metadata.json @@ -39,7 +39,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "10", - "11" + "11", + "12" ] }, { 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| From b6eee441e8e3194f0408931a885e314748188aaa Mon Sep 17 00:00:00 2001 From: Amit Karsale Date: Wed, 13 Nov 2024 14:28:26 +0530 Subject: [PATCH 07/12] (CAT-2158) Upgrade rexml to address CVE-2024-49761 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 8e9f845e1..2d8e1608b 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ group :development do gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "rexml", '>= 3.0.0', '< 3.2.7', require: false + gem "rexml", '>= 3.3.9', require: false end group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false From 9ec10807c96447cdfb92cf915d19cdf260d6b022 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sat, 7 Dec 2024 21:16:28 +0000 Subject: [PATCH 08/12] Release prep v16.1.0 --- CHANGELOG.md | 15 ++++++++++++++- metadata.json | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f67cae79f..9e55f3a5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ 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.1.0](https://github.com/puppetlabs/puppetlabs-mysql/tree/v16.1.0) - 2024-12-07 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-mysql/compare/v16.0.0...v16.1.0) + +### Fixed + +- Fix backup/rotation with multiple excluded databases [#1610](https://github.com/puppetlabs/puppetlabs-mysql/pull/1610) ([BuJo](https://github.com/BuJo)) + +### Other + +- (CAT-2158) Upgrade rexml to address CVE-2024-49761 [#1656](https://github.com/puppetlabs/puppetlabs-mysql/pull/1656) ([amitkarsale](https://github.com/amitkarsale)) +- (CAT-2100) Add Debian 12 support [#1653](https://github.com/puppetlabs/puppetlabs-mysql/pull/1653) ([shubhamshinde360](https://github.com/shubhamshinde360)) + ## [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 +855,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/metadata.json b/metadata.json index e7234e88f..f2be560d2 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-mysql", - "version": "16.0.0", + "version": "16.1.0", "author": "puppetlabs", "summary": "Installs, configures, and manages the MySQL service.", "license": "Apache-2.0", From e98d4ebe82d3de842e5dea5cd5c3c99de7edcb5a Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 16 Dec 2024 06:19:41 +0000 Subject: [PATCH 09/12] Release prep v16.2.0 --- CHANGELOG.md | 14 +++++++++----- metadata.json | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e55f3a5e..f90f52695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,18 +5,22 @@ 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.1.0](https://github.com/puppetlabs/puppetlabs-mysql/tree/v16.1.0) - 2024-12-07 +## [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) -### Fixed +### Added -- Fix backup/rotation with multiple excluded databases [#1610](https://github.com/puppetlabs/puppetlabs-mysql/pull/1610) ([BuJo](https://github.com/BuJo)) +- (CAT-2100) Add Debian 12 support [#1653](https://github.com/puppetlabs/puppetlabs-mysql/pull/1653) ([shubhamshinde360](https://github.com/shubhamshinde360)) -### Other +### Fixed - (CAT-2158) Upgrade rexml to address CVE-2024-49761 [#1656](https://github.com/puppetlabs/puppetlabs-mysql/pull/1656) ([amitkarsale](https://github.com/amitkarsale)) -- (CAT-2100) Add Debian 12 support [#1653](https://github.com/puppetlabs/puppetlabs-mysql/pull/1653) ([shubhamshinde360](https://github.com/shubhamshinde360)) +- 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 diff --git a/metadata.json b/metadata.json index f2be560d2..65ee44dcd 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-mysql", - "version": "16.1.0", + "version": "16.2.0", "author": "puppetlabs", "summary": "Installs, configures, and manages the MySQL service.", "license": "Apache-2.0", From 48c7e73e113064b432bee925a04420f365ddde8a Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Wed, 19 Mar 2025 10:55:10 -0400 Subject: [PATCH 10/12] debug: force mariadb --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index c53c4f6cd..6c2e6be25 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -61,7 +61,7 @@ } } default: { - $provider = 'mysql' + $provider = 'mariadb' } } From 6164cc53227d82c3c87d2847686c068f8cc214ef Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Mon, 24 Mar 2025 12:09:37 -0400 Subject: [PATCH 11/12] debug: remove mysql Force mariadb on everything --- lib/puppet/provider/mysql.rb | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) 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") From f612f355e57bdbcc711b08b9f7ca26d925f56c73 Mon Sep 17 00:00:00 2001 From: David Pascoe-Deslauriers Date: Mon, 24 Mar 2025 17:01:11 -0400 Subject: [PATCH 12/12] fix(commands): hardcode hardcoded commands to be the mariadb values --- lib/puppet/provider/mysql_database/mysql.rb | 2 +- lib/puppet/provider/mysql_datadir/mysql.rb | 2 +- lib/puppet/provider/mysql_grant/mysql.rb | 2 +- lib/puppet/provider/mysql_plugin/mysql.rb | 2 +- lib/puppet/provider/mysql_user/mysql.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) 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 b552a5620..1e1f3d2ea 100644 --- a/lib/puppet/provider/mysql_user/mysql.rb +++ b/lib/puppet/provider/mysql_user/mysql.rb @@ -3,7 +3,7 @@ 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.