puppetlabs/puppetlabs-mysql

Creating user with mysql::db failed on version 16

Closed this issue · 1 comments

Describe the Bug

When upgrading from v14 to v16, I've encountered the following error:

Error: /Stage[main]/Profile::Test/Mysql::Db[test]/Mysql_user[test@localhost]/password_hash: change from [old password hash redacted] to [new password hash redacted] failed: Only mysql_native_password (*ABCD...XXX) hashes are supported.

I think that this problem only occurs when using a Puppet server.

Expected Behavior

The password should not be changed since the configuration didn't change, and the run must be successful.

Steps to Reproduce

Add a configuration like:

mysql::db { 'test_db':
  user     => 'test_user',
  password => 'test_password',
}

Environment

  • Debian 12
  • mysql module 16.0.0
  • Puppet 7.29.1

Additional Context

This seems to be caused by #1569 . While investigating the bug, I've noticed that in the puppetserver log we have:

Puppet Mysql_user[test@127.0.0.1]['password_hash'] contains a Deferred value. It will be converted to the String 'Deferred({'name' => 'mysql::password', 'arguments' => ['XXXXXXXXXXXX']})

I think that this problem is caused by using ensure_resource with a parameter containing a Deferred function :

ensure_resource('mysql_user', "${user}@${host}", $user_resource)

I've figured out that we have in our Puppet configuration :

preferred_serialization_format = pson

Removing this line fix the problem. Sorry for the bother.