Forge Home

mysql

Installs, configures, and manages the MySQL service.

7,267,945 downloads

5,367 latest version

4.7 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 16.0.0 (latest)
  • 15.0.0
  • 14.0.0
  • 13.3.0
  • 13.2.0
  • 13.1.0
  • 13.0.1
  • 13.0.0
  • 12.0.3
  • 12.0.2
  • 12.0.1
  • 12.0.0
  • 11.1.0
  • 11.0.3
  • 11.0.2
  • 11.0.1
  • 11.0.0
  • 10.10.0
  • 10.9.1
  • 10.9.0
  • 10.8.0
  • 10.7.1
  • 10.7.0
  • 10.6.0
  • 10.5.0
  • 10.4.0
  • 10.3.0
  • 10.2.1
  • 10.2.0
  • 10.1.0
  • 10.0.0
  • 9.1.0
  • 9.0.0
  • 8.1.0
  • 8.0.1
  • 8.0.0
  • 7.0.0
  • 6.2.0
  • 6.1.0
  • 6.0.0
  • 5.4.0
  • 5.3.0
  • 5.2.1
  • 5.2.0
  • 5.1.0
  • 5.0.0
  • 4.0.1
  • 4.0.0
  • 3.11.0
  • 3.10.0
  • 3.9.0
  • 3.8.0
  • 3.7.0
  • 3.6.2
  • 3.6.1
  • 3.6.0
  • 3.5.0
  • 3.4.0
  • 3.3.0
  • 3.2.0
  • 3.1.0
  • 3.0.0
  • 2.3.1
  • 2.3.0
  • 2.2.3
  • 2.2.2
  • 2.2.1
  • 2.2.0 (deleted)
  • 2.1.0
  • 2.0.1
  • 2.0.0
  • 2.0.0-rc5 (pre-release)
  • 2.0.0-rc4 (pre-release)
  • 2.0.0-rc3 (pre-release)
  • 2.0.0-rc2 (pre-release)
  • 2.0.0-rc1 (pre-release)
  • 1.0.0
  • 0.9.0
  • 0.8.1
  • 0.8.0
  • 0.7.1
  • 0.7.0
  • 0.6.1
  • 0.6.0
  • 0.5.0
  • 0.4.0
  • 0.3.0
  • 0.2.0
  • 0.0.1
released Jul 11th 2024
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
  • Puppet >= 7.0.0 < 9.0.0
  • , , , , , , , ,
Tasks:
  • export
  • sql

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'puppetlabs-mysql', '16.0.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add puppetlabs-mysql
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install puppetlabs-mysql --version 16.0.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

puppetlabs/mysql — version 16.0.0 Jul 11th 2024

Reference

Table of Contents

Classes

Public Classes

Private Classes

  • mysql::backup::mysqlbackup: Manage the mysqlbackup client.
  • mysql::backup::mysqldump: "Provider" for mysqldump
  • mysql::backup::xtrabackup: "Provider" for Percona XtraBackup/MariaBackup
  • mysql::bindings::client_dev: Private class for installing client development bindings
  • mysql::bindings::daemon_dev: Private class for installing daemon development bindings
  • mysql::bindings::java: Private class for installing java language bindings.
  • mysql::bindings::perl: Private class for installing perl language bindings.
  • mysql::bindings::php: Private class for installing php language bindings
  • mysql::bindings::python: Private class for installing python language bindings
  • mysql::bindings::ruby: Private class for installing ruby language bindings
  • mysql::client::install: Private class for MySQL client install.
  • mysql::params: Params class.
  • mysql::server::account_security: Private class for ensuring localhost accounts do not exist
  • mysql::server::config: Private class for MySQL server configuration.
  • mysql::server::install: Private class for managing MySQL package.
  • mysql::server::installdb: Builds initial databases on installation.
  • mysql::server::managed_dirs: Binary log configuration requires the mysql user to be present. This must be done after package install.
  • mysql::server::providers: Convenience class to call each of the three providers with the corresponding hashes provided in mysql::server.
  • mysql::server::root_password: Private class for managing the root password
  • mysql::server::service: Private class for managing the MySQL service

Defined types

  • mysql::db: Create and configure a MySQL database.

Resource types

Public Resource types

Private Resource types

  • mysql_datadir: Manage MySQL datadirs with mysql_install_db OR mysqld (5.7.6 and above).

Functions

  • mysql::innobackupex_args: This function populates and returns the string of arguments which later gets injected in template. Arguments that return string holds is conditional and decided by the the input given to function.
  • mysql::normalise_and_deepmerge: Recursively merges two or more hashes together, normalises keys with differing use of dashes and underscores.
  • mysql::password: Hash a string as mysql's "PASSWORD()" function would do it
  • mysql::strip_hash: When given a hash this function strips out all blank entries.
  • mysql_password: DEPRECATED. Use the namespaced function mysql::password instead.

Data types

  • Mysql::Options: A hash of options structured like the override_options, but not merged with the default options.

Tasks

  • export: Allows you to backup your database to local file.
  • sql: Allows you to execute arbitary SQL

Classes

mysql::bindings

Parent class for MySQL bindings.

Examples

Install Ruby language bindings
class { 'mysql::bindings':
  ruby_enable           => true,
  ruby_package_ensure   => 'present',
  ruby_package_name     => 'ruby-mysql-2.7.1-1mdv2007.0.sparc.rpm',
  ruby_package_provider => 'rpm',
}

Parameters

The following parameters are available in the mysql::bindings class:

install_options

Data type: Optional[Array[String[1]]]

Passes install_options array to managed package resources. You must pass the appropriate options for the package manager(s).

Default value: undef

java_enable

Data type: Boolean

Specifies whether ::mysql::bindings::java should be included. Valid values are true, false.

Default value: false

perl_enable

Data type: Boolean

Specifies whether mysql::bindings::perl should be included. Valid values are true, false.

Default value: false

php_enable

Data type: Boolean

Specifies whether mysql::bindings::php should be included. Valid values are true, false.

Default value: false

python_enable

Data type: Boolean

Specifies whether mysql::bindings::python should be included. Valid values are true, false.

Default value: false

ruby_enable

Data type: Boolean

Specifies whether mysql::bindings::ruby should be included. Valid values are true, false.

Default value: false

client_dev

Data type: Boolean

Specifies whether ::mysql::bindings::client_dev should be included. Valid values are true', false.

Default value: false

daemon_dev

Data type: Boolean

Specifies whether ::mysql::bindings::daemon_dev should be included. Valid values are true, false.

Default value: false

java_package_ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if java_enable => true.

Default value: $mysql::params::java_package_ensure

java_package_name

Data type: String[1]

The name of the Java package to install. Only applies if java_enable => true.

Default value: $mysql::params::java_package_name

java_package_provider

Data type: Optional[String[1]]

The provider to use to install the Java package. Only applies if java_enable => true.

Default value: $mysql::params::java_package_provider

perl_package_ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if perl_enable => true.

Default value: $mysql::params::perl_package_ensure

perl_package_name

Data type: String[1]

The name of the Perl package to install. Only applies if perl_enable => true.

Default value: $mysql::params::perl_package_name

perl_package_provider

Data type: Optional[String[1]]

The provider to use to install the Perl package. Only applies if perl_enable => true.

Default value: $mysql::params::perl_package_provider

php_package_ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if php_enable => true.

Default value: $mysql::params::php_package_ensure

php_package_name

Data type: String[1]

The name of the PHP package to install. Only applies if php_enable => true.

Default value: $mysql::params::php_package_name

php_package_provider

Data type: Optional[String[1]]

The provider to use to install the PHP package. Only applies if php_enable => true.

Default value: $mysql::params::php_package_provider

python_package_ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if python_enable => true.

Default value: $mysql::params::python_package_ensure

python_package_name

Data type: String[1]

The name of the Python package to install. Only applies if python_enable => true.

Default value: $mysql::params::python_package_name

python_package_provider

Data type: Optional[String[1]]

The provider to use to install the Python package. Only applies if python_enable => true.

Default value: $mysql::params::python_package_provider

ruby_package_ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if ruby_enable => true.

Default value: $mysql::params::ruby_package_ensure

ruby_package_name

Data type: String[1]

The name of the Ruby package to install. Only applies if ruby_enable => true.

Default value: $mysql::params::ruby_package_name

ruby_package_provider

Data type: Optional[String[1]]

What provider should be used to install the package.

Default value: $mysql::params::ruby_package_provider

client_dev_package_ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if client_dev => true.

Default value: $mysql::params::client_dev_package_ensure

client_dev_package_name

Data type: Optional[String[1]]

The name of the client_dev package to install. Only applies if client_dev => true.

Default value: $mysql::params::client_dev_package_name

client_dev_package_provider

Data type: Optional[String[1]]

The provider to use to install the client_dev package. Only applies if client_dev => true.

Default value: $mysql::params::client_dev_package_provider

daemon_dev_package_ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if daemon_dev => true.

Default value: $mysql::params::daemon_dev_package_ensure

daemon_dev_package_name

Data type: String[1]

The name of the daemon_dev package to install. Only applies if daemon_dev => true.

Default value: $mysql::params::daemon_dev_package_name

daemon_dev_package_provider

Data type: Optional[String[1]]

The provider to use to install the daemon_dev package. Only applies if daemon_dev => true.

Default value: $mysql::params::daemon_dev_package_provider

mysql::client

Installs and configures the MySQL client.

Examples

Install the MySQL client
class {'::mysql::client':
  package_name    => 'mysql-client',
  package_ensure  => 'present',
  bindings_enable => true,
}

Parameters

The following parameters are available in the mysql::client class:

bindings_enable

Data type: Boolean

Whether to automatically install all bindings. Valid values are true, false. Default to false.

Default value: $mysql::params::bindings_enable

install_options

Data type: Optional[Array[String[1]]]

Array of install options for managed package resources. You must pass the appropriate options for the package manager.

Default value: undef

package_ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Whether the MySQL package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'.

Default value: $mysql::params::client_package_ensure

package_manage

Data type: Boolean

Whether to manage the MySQL client package. Defaults to true.

Default value: $mysql::params::client_package_manage

package_name

Data type: String[1]

The name of the MySQL client package to install.

Default value: $mysql::params::client_package_name

package_provider

Data type: Optional[String[1]]

Specify the provider of the package. Optional. Valid value is a String.

Default value: undef

package_source

Data type: Optional[String[1]]

Specify the path to the package source. Optional. Valid value is a String

Default value: undef

mysql::server

Installs and configures the MySQL server.

Examples

Install MySQL Server
class { '::mysql::server':
  package_name            => 'mysql-server',
  package_ensure          => '5.7.1+mysql~trusty',
  root_password           => 'strongpassword',
  remove_default_accounts => true,
}

Parameters

The following parameters are available in the mysql::server class:

config_file

Data type: String[1]

The location, as a path, of the MySQL configuration file.

Default value: $mysql::params::config_file

config_file_mode

Data type: String[1]

The MySQL configuration file's permissions mode.

Default value: '0644'

includedir

Data type: Optional[String]

The location, as a path, of !includedir for custom configuration overrides.

Default value: $mysql::params::includedir

install_options

Data type: Optional[Array[String[1]]]

Passes install_options array to managed package resources. You must pass the appropriate options for the specified package manager

Default value: undef

manage_config_file

Data type: Variant[Boolean, String[1]]

Whether the MySQL configuration file should be managed. Valid values are true, false. Defaults to true.

Default value: true

options

Data type: Mysql::Options

A hash of options structured like the override_options, but not merged with the default options. Use this if you don't want your options merged with the default options.

Default value: {}

override_options

Data type: Hash

Specifies override options to pass into MySQL. Structured like a hash in the my.cnf file: See above for usage details.

Default value: {}

package_ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Whether the package exists or should be a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Defaults to 'present'.

Default value: 'present'

package_manage

Data type: Boolean

Whether to manage the MySQL server package. Defaults to true.

Default value: true

package_name

Data type: String[1]

The name of the MySQL server package to install.

Default value: $mysql::params::server_package_name

package_provider

Data type: Optional[String[1]]

Define a specific provider for package install.

Default value: undef

package_source

Data type: Optional[String[1]]

The location of the package source (require for some package provider)

Default value: undef

purge_conf_dir

Data type: Variant[Boolean, String[1]]

Whether the includedir directory should be purged. Valid values are true, false. Defaults to false.

Default value: false

remove_default_accounts

Data type: Variant[Boolean, String[1]]

Specifies whether to automatically include mysql::server::account_security. Valid values are true, false. Defaults to false.

Default value: false

restart

Data type: Variant[Boolean, String[1]]

Whether the service should be restarted when things change. Valid values are true, false. Defaults to false.

Default value: false

root_group

Data type: String[1]

The name of the group used for root. Can be a group name or a group ID. See more about the group.

Default value: $mysql::params::root_group

managed_dirs

Data type: Optional[Array[String[1]]]

An array containing all directories to be managed.

Default value: $mysql::params::managed_dirs

mysql_group

Data type: String[1]

The name of the group of the MySQL daemon user. Can be a group name or a group ID. See more about the group.

Default value: $mysql::params::mysql_group

mycnf_owner

Data type: Optional[String[1]]

Name or user-id who owns the mysql-config-file.

Default value: undef

mycnf_group

Data type: Optional[String[1]]

Name or group-id which owns the mysql-config-file.

Default value: undef

root_password

Data type: Variant[String, Sensitive[String]]

The MySQL root password. Puppet attempts to set the root password and update /root/.my.cnf with it. This is required if create_root_user or create_root_my_cnf are true. If root_password is 'UNSET', then create_root_user and create_root_my_cnf are assumed to be false --- that is, the MySQL root user and /root/.my.cnf are not created. Password changes are supported; however, the old password must be set in /root/.my.cnf. Effectively, Puppet uses the old password, configured in /root/my.cnf, to set the new password in MySQL, and then updates /root/.my.cnf with the new password.

Default value: 'UNSET'

service_enabled

Data type: Variant[Boolean, String[1]]

Specifies whether the service should be enabled. Valid values are true, false. Defaults to true.

Default value: true

service_manage

Data type: Variant[Boolean, String[1]]

Specifies whether the service should be managed. Valid values are true, false. Defaults to true.

Default value: true

service_name

Data type: String[1]

The name of the MySQL server service. Defaults are OS dependent, defined in 'params.pp'.

Default value: $mysql::params::server_service_name

service_provider

Data type: Optional[String[1]]

The provider to use to manage the service. For Ubuntu, defaults to 'upstart'; otherwise, default is undefined.

Default value: undef

create_root_user

Data type: Boolean

Whether root user should be created. Valid values are true, false. Defaults to true. This is useful for a cluster setup with Galera. The root user has to be created only once. You can set this parameter true on one node and set it to false on the remaining nodes.

Default value: true

create_root_my_cnf

Data type: Boolean

Whether to create /root/.my.cnf. Valid values are true, false. Defaults to true. create_root_my_cnf allows creation of /root/.my.cnf independently of create_root_user. You can use this for a cluster setup with Galera where you want /root/.my.cnf to exist on all nodes.

Default value: true

create_root_login_file

Data type: Boolean

Whether to create a login file for root. Valid values are 'true', 'false'.

Default value: false

login_file

Data type: Optional[String[1]]

Specify the login file.

Default value: undef

users

Data type: Hash

Optional hash of users to create, which are passed to mysql_user.

Default value: {}

grants

Data type: Hash

Optional hash of grants, which are passed to mysql_grant.

Default value: {}

databases

Data type: Hash

Optional hash of databases to create, which are passed to mysql_database.

Default value: {}

reload_on_config_change

Data type: Boolean

By default, a my.cnf change won't reload/restart the database. Turn this flag to true to enable it

Default value: false

enabled

Data type: Optional[Variant[String[1], Boolean]]

Deprecated

Default value: undef

manage_service

Data type: Optional[Variant[String[1], Boolean]]

Deprecated

Default value: undef

old_root_password

Data type: Optional[Variant[String, Sensitive[String]]]

This parameter no longer does anything. It exists only for backwards compatibility. See the root_password parameter above for details on changing the root password.

Default value: undef

mysql::server::backup

Create and manage a MySQL backup.

Examples

Create a basic MySQL backup:
class { 'mysql::server':
  root_password           => 'password'
}
class { 'mysql::server::backup':
  backupuser              => 'myuser',
  backuppassword          => 'mypassword',
  backupdir               => '/tmp/backups',
}
Create a basic MySQL backup using mariabackup:
class { 'mysql::server':
  root_password           => 'password'
}
class { 'mysql::server::backup':
  backupmethod            => 'mariabackup',
  backupmethod_package    => 'mariadb-backup'
  provider                => 'xtrabackup',
  backupdir               => '/tmp/backups',
}

Parameters

The following parameters are available in the mysql::server::backup class:

backupuser

Data type: Optional[String[1]]

MySQL user to create with backup administrator privileges.

Default value: undef

backuppassword

Data type: Optional[Variant[String, Sensitive[String]]]

Password to create for backupuser.

Default value: undef

backupdir

Data type: Optional[String[1]]

Directory to store backup.

Default value: undef

backupdirmode

Data type: String[1]

Permissions applied to the backup directory. This parameter is passed directly to the file resource.

Default value: '0700'

backupdirowner

Data type: String[1]

Owner for the backup directory. This parameter is passed directly to the file resource.

Default value: 'root'

backupdirgroup

Data type: String[1]

Group owner for the backup directory. This parameter is passed directly to the file resource.

Default value: $mysql::params::root_group

backupcompress

Data type: Boolean

Whether or not to compress the backup (when using the mysqldump or xtrabackup provider)

Default value: true

backupmethod

Data type: Optional[String[1]]

The execution binary for backing up. ex. mysqldump, xtrabackup, mariabackup

Default value: undef

backup_success_file_path

Data type: String[1]

Specify a path where upon successfull backup a file should be created for checking purposes.

Default value: '/tmp/mysqlbackup_success'

backuprotate

Data type: Variant[String[1], Integer]

Backup rotation interval in 24 hour periods.

Default value: 30

ignore_events

Data type: Boolean

Ignore the mysql.event table.

Default value: true

delete_before_dump

Data type: Boolean

Whether to delete old .sql files before backing up. Setting to true deletes old files before backing up, while setting to false deletes them after backup.

Default value: false

backupdatabases

Data type: Array[String[1]]

Databases to backup (required if using xtrabackup provider). By default [] will back up all databases.

Default value: []

file_per_database

Data type: Boolean

Use file per database mode creating one file per database backup.

Default value: false

include_routines

Data type: Boolean

Dump stored routines (procedures and functions) from dumped databases when doing a file_per_database backup.

Default value: false

include_triggers

Data type: Boolean

Dump triggers for each dumped table when doing a file_per_database backup.

Default value: false

incremental_backups

Data type: Boolean

A flag to activate/deactivate incremental backups. Currently only supported by the xtrabackup provider.

Default value: true

ensure

Data type: Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]]

Default value: 'present'

time

Data type: Variant[Array[String[1]], Array[Integer]]

An array of two elements to set the backup time. Allows ['23', '5'] (i.e., 23:05) or ['3', '45'] (i.e., 03:45) for HH:MM times.

Default value: ['23', '5']

prescript

Data type: Variant[Boolean, String[1], Array[String[1]]]

A script that is executed before the backup begins.

Default value: false

postscript

Data type: Variant[Boolean, String[1], Array[String[1]]]

A script that is executed when the backup is finished. This could be used to sync the backup to a central store. This script can be either a single line that is directly executed or a number of lines supplied as an array. It could also be one or more externally managed (executable) files.

Default value: false

execpath

Data type: String[1]

Allows you to set a custom PATH should your MySQL installation be non-standard places. Defaults to /usr/bin:/usr/sbin:/bin:/sbin.

Default value: '/usr/bin:/usr/sbin:/bin:/sbin'

provider

Data type: Enum['xtrabackup', 'mysqldump', 'mysqlbackup']

Sets the server backup implementation. Valid values are: xtrabackup, mysqldump, mysqlbackup

Default value: 'mysqldump'

maxallowedpacket

Data type: String[1]

Defines the maximum SQL statement size for the backup dump script. The default value is 1MB, as this is the default MySQL Server value.

Default value: '1M'

optional_args

Data type: Array[String[1]]

Specifies an array of optional arguments which should be passed through to the backup tool. (Supported by the xtrabackup and mysqldump providers.)

Default value: []

install_cron

Data type: Boolean

Manage installation of cron package

Default value: true

compression_command

Data type: Optional[String[1]]

Configure the command used to compress the backup (when using the mysqldump provider). Make sure the command exists on the target system. Packages for it are NOT automatically installed.

Default value: undef

compression_extension

Data type: Optional[String[1]]

Configure the file extension for the compressed backup (when using the mysqldump provider)

Default value: undef

backupmethod_package

Data type: String[1]

The package which provides the binary specified by the backupmethod parameter.

Default value: $mysql::params::xtrabackup_package_name

excludedatabases

Data type: Array[String]

Give a list of excluded databases when using file_per_database, e.g.: [ 'information_schema', 'performance_schema' ]

Default value: []

Defined types

mysql::db

Create and configure a MySQL database.

Examples

Create a database
mysql::db { 'mydb':
  user     => 'myuser',
  password => 'mypass',
  host     => 'localhost',
  grant    => ['SELECT', 'UPDATE'],
}

Parameters

The following parameters are available in the mysql::db defined type:

name

The name of the database to create. Database names must:

  • not be longer than 64 characters.
  • not contain '/' '\' or '.' characters.
  • not contain characters that are not permitted in file names.
  • not end with space characters.
user

Data type: String[1]

The user for the database you're creating.

password

Data type: Variant[String, Sensitive[String]]

The password for $user for the database you're creating.

tls_options

Data type: Optional[Array[String[1]]]

The tls_options for $user for the database you're creating.

Default value: undef

dbname

Data type: String

The name of the database to create.

Default value: $name

charset

Data type: String[1]

The character set for the database. Must have the same value as collate to avoid corrective changes. See https://dev.mysql.com/doc/refman/8.0/en/charset-mysql.html for charset and collation pairs.

Default value: 'utf8mb3'

collate

Data type: String[1]

The collation for the database. Must have the same value as charset to avoid corrective changes. See https://dev.mysql.com/doc/refman/8.0/en/charset-mysql.html for charset and collation pairs.

Default value: 'utf8mb3_general_ci'

host

Data type: String[1]

The host to use as part of user@host for grants.

Default value: 'localhost'

grant

Data type: Variant[String[1], Array[String[1]]]

The privileges to be granted for user@host on the database.

Default value: 'ALL'

grant_options

Data type: Optional[Variant[String[1], Array[String[1]]]]

The grant_options for the grant for user@host on the database.

Default value: undef

sql

Data type: Optional[Array]

The path to the sqlfile you want to execute. This can be an array containing one or more file paths.

Default value: undef

enforce_sql

Data type: Boolean

Specifies whether executing the sqlfiles should happen on every run. If set to false, sqlfiles only run once.

Default value: false

ensure

Data type: Enum['absent', 'present']

Specifies whether to create the database. Valid values are 'present', 'absent'. Defaults to 'present'.

Default value: 'present'

import_timeout

Data type: Integer

Timeout, in seconds, for loading the sqlfiles. Defaults to 300.

Default value: 300

import_cat_cmd

Data type: Enum['cat', 'zcat', 'bzcat']

Command to read the sqlfile for importing the database. Useful for compressed sqlfiles. For example, you can use 'zcat' for .gz files.

Default value: 'cat'

mysql_exec_path

Data type: Optional[String]

Specify the path in which mysql has been installed if done in the non-standard bin/sbin path.

Default value: undef

Resource types

mysql_database

Manage a MySQL database.

Properties

The following properties are available in the mysql_database type.

charset

Valid values: %r{^\S+$}

The CHARACTER SET setting for the database

Default value: utf8

collate

Valid values: %r{^\S+$}

The COLLATE setting for the database

Default value: utf8_general_ci

ensure

Valid values: present, absent

The basic property that the resource should be in.

Default value: present

Parameters

The following parameters are available in the mysql_database type.

name

namevar

The name of the MySQL database to manage.

provider

The specific backend to use for this mysql_database resource. You will seldom need to specify this --- Puppet will usually discover the appropriate provider for your platform.

mysql_grant

Manage a MySQL user's rights.

Properties

The following properties are available in the mysql_grant type.

ensure

Valid values: present, absent

The basic property that the resource should be in.

Default value: present

options

Options to grant.

privileges

Privileges for user

table

Valid values: %r{.*\..*}, %r{^[0-9a-zA-Z$_]*@[\w%.:\-/]*$}

Table to apply privileges to.

user

User to operate on.

Parameters

The following parameters are available in the mysql_grant type.

name

namevar

Name to describe the grant.

provider

The specific backend to use for this mysql_grant resource. You will seldom need to specify this --- Puppet will usually discover the appropriate provider for your platform.

mysql_login_path

This type provides Puppet with the capabilities to store authentication credentials in an obfuscated login path file named .mylogin.cnf created with the mysql_config_editor utility. Supports only MySQL Community Edition > v5.6.6.

Examples

mysql_login_path { 'local_socket':
  owner    => 'root',
  host     => 'localhost',
  user     => 'root',
  password => Sensitive('secure'),
  socket   => '/var/run/mysql/mysql.sock',
  ensure   => present,
}

mysql_login_path { 'local_tcp':
  owner    => 'root',
  host     => '127.0.0.1',
  user     => 'root',
  password => Sensitive('more_secure'),
  port     => 3306,
  ensure   => present,
}

Properties

The following properties are available in the mysql_login_path type.

ensure

Data type: Enum[present, absent]

Whether this resource should be present or absent on the target system.

host

Data type: Optional[String]

Host name to be entered into the login path.

password

Data type: Optional[Sensitive[String[1]]]

Password to be entered into login path

port

Data type: Optional[Integer[0,65535]]

Port number to be entered into login path.

socket

Data type: Optional[String]

Socket path to be entered into login path

user

Data type: Optional[String]

Username to be entered into the login path.

Parameters

The following parameters are available in the mysql_login_path type.

name

namevar

Data type: String

Name of the login path you want to manage.

owner

namevar

Data type: String

The user to whom the logon path should belong.

Default value: root

mysql_plugin

Manage MySQL plugins.

Examples

mysql_plugin { 'some_plugin':
  soname => 'some_pluginlib.so',
}

Properties

The following properties are available in the mysql_plugin type.

ensure

Valid values: present, absent

The basic property that the resource should be in.

Default value: present

soname

Valid values: %r{^\w+\.\w+$}

The name of the library

Parameters

The following parameters are available in the mysql_plugin type.

name

namevar

The name of the MySQL plugin to manage.

provider

The specific backend to use for this mysql_plugin resource. You will seldom need to specify this --- Puppet will usually discover the appropriate provider for your platform.

mysql_user

Manage a MySQL user. This includes management of users password as well as privileges.

Properties

The following properties are available in the mysql_user type.

ensure

Valid values: present, absent

The basic property that the resource should be in.

Default value: present

max_connections_per_hour

Valid values: %r{\d+}

Max connections per hour for the user. 0 means no (or global) limit.

max_queries_per_hour

Valid values: %r{\d+}

Max queries per hour for the user. 0 means no (or global) limit.

max_updates_per_hour

Valid values: %r{\d+}

Max updates per hour for the user. 0 means no (or global) limit.

max_user_connections

Valid values: %r{\d+}

Max concurrent connections for the user. 0 means no (or global) limit.

password_hash

Valid values: %r{\w*}

The password hash of the user. Use mysql::password() for creating such a hash.

plugin

Valid values: %r{\w+}

The authentication plugin of the user.

tls_options

Options to that set the TLS-related REQUIRE attributes for the user.

Parameters

The following parameters are available in the mysql_user type.

name

namevar

The name of the user. This uses the 'username@hostname' or username@hostname.

provider

The specific backend to use for this mysql_user resource. You will seldom need to specify this --- Puppet will usually discover the appropriate provider for your platform.

Functions

mysql::innobackupex_args

Type: Ruby 4.x API

This function populates and returns the string of arguments which later gets injected in template. Arguments that return string holds is conditional and decided by the the input given to function.

mysql::innobackupex_args(Optional[String] $backupuser, Boolean $backupcompress, Optional[Variant[String, Sensitive[String]]] $backuppassword_unsensitive, Array[String[1]] $backupdatabases, Array[String[1]] $optional_args)

The mysql::innobackupex_args function.

Returns: Variant[String] String Generated on the basis of provided values.

backupuser

Data type: Optional[String]

The user to use for the backup.

backupcompress

Data type: Boolean

If the backup should be compressed.

backuppassword_unsensitive

Data type: Optional[Variant[String, Sensitive[String]]]

The password to use for the backup.

backupdatabases

Data type: Array[String[1]]

The databases to backup.

optional_args

Data type: Array[String[1]]

Additional arguments to pass to innobackupex.

mysql::normalise_and_deepmerge

Type: Ruby 4.x API

  • When there is a duplicate key that is a hash, they are recursively merged.
  • When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
  • When there are conficting uses of dashes and underscores in two keys (which mysql would otherwise equate), the rightmost style will win.

Examples

$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
$merged_hash = mysql::normalise_and_deepmerge($hash1, $hash2)
# The resulting hash is equivalent to:
# $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }

mysql::normalise_and_deepmerge(Any *$args)

  • When there is a duplicate key that is a hash, they are recursively merged.
  • When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
  • When there are conficting uses of dashes and underscores in two keys (which mysql would otherwise equate), the rightmost style will win.

Returns: Any hash The given hash normalised

Examples
$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
$merged_hash = mysql::normalise_and_deepmerge($hash1, $hash2)
# The resulting hash is equivalent to:
# $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
*args

Data type: Any

Hash to be normalised

mysql::password

Type: Ruby 4.x API

Hash a string as mysql's "PASSWORD()" function would do it

mysql::password(Variant[String, Sensitive[String]] $password, Optional[Boolean] $sensitive)

Hash a string as mysql's "PASSWORD()" function would do it

Returns: Variant[String, Sensitive[String]] hash The mysql password hash from the clear text password.

password

Data type: Variant[String, Sensitive[String]]

Plain text password.

sensitive

Data type: Optional[Boolean]

If the mysql password hash should be of datatype Sensitive[String]

mysql::strip_hash

Type: Ruby 4.x API

When given a hash this function strips out all blank entries.

mysql::strip_hash(Hash $hash)

The mysql::strip_hash function.

Returns: Hash hash The given hash with all blank entries removed

hash

Data type: Hash

Hash to be stripped

mysql_password

Type: Ruby 4.x API

DEPRECATED. Use the namespaced function mysql::password instead.

mysql_password(Variant[String, Sensitive[String]] $password, Optional[Boolean] $sensitive)

The mysql_password function.

Returns: Variant[String, Sensitive[String]] The mysql password hash from the 4.x function mysql::password.

password

Data type: Variant[String, Sensitive[String]]

Plain text password.

sensitive

Data type: Optional[Boolean]

If the mysql password hash should be of datatype Sensitive[String]

Data types

Mysql::Options

Use this if you don’t want your options merged with the default options.

Alias of Hash[String, Hash]

Tasks

export

Allows you to backup your database to local file.

Supports noop? false

Parameters

database

Data type: Optional[String[1]]

Database to connect to

user

Data type: Optional[String[1]]

The user

password

Data type: Optional[String[1]]

The password

file

Data type: String[1]

Path to file you want backup to

sql

Allows you to execute arbitary SQL

Supports noop? false

Parameters

database

Data type: Optional[String[1]]

Database to connect to

user

Data type: Optional[String[1]]

The user

password

Data type: Optional[String[1]]

The password

sql

Data type: String[1]

The SQL you want to execute