puppetlabs-mysql icon indicating copy to clipboard operation
puppetlabs-mysql copied to clipboard

How to install MySQL instead of MariaDB on Ubuntu 22.04?

Open tetsuo13 opened this issue 1 year ago • 4 comments

Describe the Bug

Beginning with v13.0.0 of this module, the default behavior on Ubuntu versions 20.04 and greater is to install MariaDB. As of this writing, the README doesn't mention this behavior nor how to install MySQL instead. I tried using the package_name parameter of "mysql-server" however that appears to have mixed results and ultimately failing to install MySQL as expected.

This behavior appears to be first documented in https://github.com/puppetlabs/puppetlabs-mysql/pull/1449#issuecomment-1489150042 with no workarounds.

Expected Behavior

With one or more parameters set, MySQL should be installed.

Steps to Reproduce

As an example, using the following

class { 'mysql::server':
    package_name => 'mysql-server',
}

on a fresh install of Ubuntu 22.04, this is the output:

Notice: Compiled catalog for server in environment production in 0.87 seconds
Notice: /Stage[main]/Mysql::Server::Config/File[/etc/mysql]/ensure: created
Notice: /Stage[main]/Mysql::Server::Config/File[/etc/mysql/conf.d]/ensure: created
Notice: /Stage[main]/Mysql::Server::Config/Exec[datadir-managed_dir-mkdir]/returns: executed successfully
Notice: /Stage[main]/Mysql::Server::Config/Exec[datadir-managed_dir-chmod]: Triggered 'refresh' from 1 event
Notice: /Stage[main]/Mysql::Server::Config/File[mysql-config-file]/ensure: defined content as '{sha256}39c740fb553b58d69cd7c18415cfc346d834cd4c6429a024ac39332a1832e5e5'
Notice: /Stage[main]/Mysql::Server::Install/Package[mysql-server]/ensure: created
Error: Systemd start for mariadb failed!
journalctl log for mariadb:
-- No entries --

Error: /Stage[main]/Mysql::Server::Service/Service[mysqld]/ensure: change from 'stopped' to 'running' failed: Systemd start for mariadb failed!
journalctl log for mariadb:
-- No entries --

Notice: /Stage[main]/Mysql::Server::Service/Exec[wait_for_mysql_socket_to_open]: Dependency Service[mysqld] has failures: true
Warning: /Stage[main]/Mysql::Server::Service/Exec[wait_for_mysql_socket_to_open]: Skipping because of failed dependencies
Warning: /Stage[main]/Mysql::Server::Root_password/Exec[remove install pass]: Skipping because of failed dependencies
Warning: /Stage[main]/Mysql::Server::Root_password/Mysql_user[root@localhost]: Skipping because of failed dependencies
Warning: /Stage[main]/Mysql::Server::Root_password/File[/root/.my.cnf]: Skipping because of failed dependencies
Warning: /Stage[main]/Mysql::Server/Anchor[mysql::server::end]: Skipping because of failed dependencies
Notice: /Stage[main]/Mysql::Client::Install/Package[mysql_client]/ensure: created
Error: Could not prefetch mysql_database provider 'mysql': Execution of '/usr/bin/mysql -NBe show databases' returned 1: ERROR 2002 (HY000): Can't connect to local server through socket '/var/run/mysqld/mysqld.sock' (2)
Notice: Applied catalog in 66.53 seconds

Environment

  • v14.0.0
  • Ubuntu 22.04

Additional Context

tetsuo13 avatar Jul 08 '23 20:07 tetsuo13

I orginally reported this and have been getting nothing but the runaround from this team. At this point the module should be renamed the puppetlabs-mariaDB module.

daehnomel avatar Jul 12 '23 16:07 daehnomel

I just tried a later version and indeed, it feels like they want to force MariaDB down our throat!

hboetes avatar Aug 04 '23 17:08 hboetes

I am having the same problem. after unsuccessfully trying a few different configurations like package_name above, I attempted to look through the module's files to see if there was some default mariaDB install commands that I could edit or remove, but I didn't even find one reference to mariaDB outside of a mysql_datadir file that isn't even related to Ubuntu. what gives? seems like I have no choice but to remove this module.

androidSalander avatar Aug 19 '23 00:08 androidSalander

The relevant configuration is https://github.com/puppetlabs/puppetlabs-mysql/blob/main/manifests/params.pp#L154-L173

    'Debian': {
      if $facts['os']['name'] == 'Debian' or $facts['os']['name'] == 'Raspbian' or
      ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '20.04') >= 0) {
        $provider = 'mariadb'
      } else {
        $provider = 'mysql'
      }
      if $provider == 'mariadb' {
        $client_package_name     = 'mariadb-client'
        $server_package_name     = 'mariadb-server'
        $server_service_name     = 'mariadb'
        $client_dev_package_name = 'libmariadbclient-dev'
        $daemon_dev_package_name = 'libmariadbd-dev'
      } else {
        $client_package_name     = 'mysql-client'
        $server_package_name     = 'mysql-server'
        $server_service_name     = 'mysql'
        $client_dev_package_name = 'libmysqlclient-dev'
        $daemon_dev_package_name = 'libmysqld-dev'
      }

I was able to override the MariaDB configuration back to mysql using the following

mysql::server::package_name: 'mysql-server'
mysql::client::package_name: 'mysql-client'
mysql::server::service_name: 'mysql'
mysql::bindings::client_dev_package_name: 'libmysqlclient-dev'
mysql::bindings::daemon_dev_package_name: 'libmysqld-dev'

However, this should just be fixed upstream in a better way.

andrewbierbaum avatar Dec 15 '23 02:12 andrewbierbaum