Skip to content

Conversation

teluq-pbrideau
Copy link

@teluq-pbrideau teluq-pbrideau commented Oct 17, 2025

Summary

Use $mysql::params::provider instead of mysql to import a database in mysql::db.

As this parameter is already configured for some OS, I decided to define this variable for every OS, and use it.

Additional Context

See #1693

Related Issues (if any)

#1693

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified. (For example puppet apply)

@teluq-pbrideau
Copy link
Author

The tests for mysql::db now fail… not sure how to retreive the $mysql::params::provider from within the test…
https://github.com/puppetlabs/puppetlabs-mysql/blob/main/spec/defines/mysql_db_spec.rb#L42

Of course this should change the mysql command:
expect(subject).to contain_exec('test_db-import').with_command('cat /tmp/test.sql | mysql test_db')

But I tried without success to retreive the variable:
let(:pre_condition) { 'include mysql::params' } and expect(subject).to contain_exec('test_db-import').with_command("cat /tmp/test.sql | #{mysql::params::provider} test_db")

Is the only option to define provider for every OS in the test?

      provider = if facts[:os]['family'] == 'RedHat'
                   'mariadb'
                elsif facts[:os]['family'] == 'Suse'
                   'mariadb'
                elsif facts[:os]['name'] == 'Debian'
                   'mariadb'
                elsif facts[:os]['name'] == 'Ubuntu'
                  if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '20') < 0 &&
                     Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '16') >= 0
                    'mysql'
                  else
                    'mariadb'
                  end
                end

With it, the test pass, but is there a cleaner way to retreive the information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant