Skip to content
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 support for the Deferred function on mysql::db #1579

Open
tuxmaster5000 opened this issue Jun 30, 2023 · 6 comments
Open

Add support for the Deferred function on mysql::db #1579

tuxmaster5000 opened this issue Jun 30, 2023 · 6 comments

Comments

@tuxmaster5000
Copy link

The mysql::db resource needs an password, but it can't received by the Deferred function of puppet.
Sample code:

mysql::db { $foo:
    user      => $foo,
    charset   => $charset,
    password  => Sensitive(Deferred(FUNCTION ,[OPTIONS])),    
  }

The use of it fails with:

parameter 'password' expects a value of type String or Sensitive[String], got Sensitive[Object[{name => 'Deferred', attributes => {'name' => Pattern[/\A[$]?[a-z][a-z0-9_](?:::[a-z][a-z0-9_])*\z/], 'arguments' => {type => Optional[Array], value => undef}}}]]

@alexjfisher
Copy link
Collaborator

Does your function return a Sensitive already (or could it be altered to)? I suspect the issue is you wrapping the Deferred in Sensitive. Also can you confirm your Puppet version?

@tuxmaster5000
Copy link
Author

I use puppet 8.
The function will return an String.
Without the Sensitive option, it will fails with:

Error: Could not set 'present' on ensure: invalid byte sequence in UTF-8 (file: /etc/puppetlabs/code/environments/production/modules/mysql/manifests/db.pp, line: 101)
Error: Could not set 'present' on ensure: invalid byte sequence in UTF-8 (file: /etc/puppetlabs/code/environments/production/modules/mysql/manifests/db.pp, line: 101)
Wrapped exception:
invalid byte sequence in UTF-8

For the char set utf8mb4 was chosen.

@alexjfisher
Copy link
Collaborator

Looking at the current version of the code, it looks like this should have worked. Can you confirm the module version you're using and also re-run with --debug --trace.

@tuxmaster5000
Copy link
Author

├── puppetlabs-mysql (v15.0.0)
here the debug output:
puppet.zip

@alexjfisher
Copy link
Collaborator

Looks like the database creation itself is failing before anything to do with the user's password.

I don't get the exact same error (which is probably mysql/mariadb version dependent), but I suspect the one I get highlights the problem.

COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'utf8mb4'

Try...

mysql::db { 'my_db':
  charset => 'utf8mb4',
  collate => 'utf8mb4_0900_ai_ci', # Or possibly 'utf8mb4_unicode_ci' depending on your mysql variant/version
}

@tuxmaster5000
Copy link
Author

Reading https://mariadb.com/kb/en/supported-character-sets-and-collations will shown that utf8mb4_general_ci will be the right.
I have tried charset =>utf8mb4 with collate=>utf8mb4_general_ci. But the error are the same. I am using MariaDB 10.11.4.
Here the last log:
debug.zip
On the command line, I can execute the last command before the error:

mysql -NBe "SHOW GRANTS FOR 'PUBLIC'@'';"
ERROR 1141 (42000) at line 1: Für Benutzer 'PUBLIC' auf Host '%' gibt es keine solche Berechtigung

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

No branches or pull requests

3 participants