-- mode: markdown; mode: visual-line; --
Configure and manage MySQL
Copyright (c) 2016 S. Varrette, H. Cartiaux, V. Plugaru, S. Diehl aka. UL HPC Management Team <hpc-sysadmins@uni.lu>
| Project Page | Sources | Documentation | Issues |
Configure and manage MySQL.
This module implements the following elements:
-
Puppet classes:
mysql
mysql::client
mysql::client::common
mysql::client::debian
mysql::client::redhat
mysql::params
mysql::server
mysql::server::common
mysql::server::debian
mysql::server::redhat
-
Puppet definitions:
mysql::command
mysql::db
mysql::user
All these components are configured through a set of variables you will find in
manifests/params.pp
.
Note: the various operations that can be conducted from this repository are piloted from a Rakefile
and assumes you have a running Ruby installation.
See docs/contributing.md
for more details on the steps you shall follow to have this Rakefile
working properly.
See metadata.json
. In particular, this module depends on
The pwgen
utility needs to be installed on the Puppetmaster, if the mysql::server
class should auto-generate the root password.
This is the main class defined in this module.
Use it as follows:
include 'mysql'
See also tests/init.pp
This class installs the MySQL client.
It accepts the following parameters:
$ensure
: Default to 'present', can be 'absent'.
This class will automatically include the appropriate specialisation class mysql::client::debian
or mysql::client::redhat
based on the OS.
Sample usage:
import mysql::client
You can then specialize the various aspects of the configuration, for instance:
class { 'mysql::client':
ensure => 'present'
}
See tests/client.pp
This class installs and configures a MySQL server.
This class accepts the following parameters:
-
$ensure
: Default: 'present'. Ensure the presence (or absence) ofmysql::server
. -
$root_password
: Default: ''. MySQL root password (left empty for having a random generated one that will be stored in the file/root/.my.cnf
). -
$root_accessfile
: Default: '/root/.my.cnf'. Configuration file path for 'root' user (containing access details). -
$datadir
: Default: '/var/lib/mysql'. MySQL data directory. -
$bind_address
: Default: '127.0.0.1'. The network service will listen on the specified address. -
$character_set
: Default: ''. Sets MySQL's character set.
This class will automatically include the appropriate specialisation class mysql::server::debian
or mysql::server::redhat
based on the OS.
Sample usage:
import mysql::server
You can then specialize the various aspects of the configuration, for instance:
class { 'mysql::server':
ensure => 'present'
}
See tests/server.pp
The definition mysql::command
executes a MySQL command (as root user).
This definition accepts the following parameters:
-
$ensure
: Default to 'present', can be 'absent'. -
$command
: If set, detail the MySQL command to execute. -
$onlyif
: If this parameter is set, then the MySQL command will only run if the command specified in the onlyif directive returns 0. -
$unless
: If this parameter is set, then the MySQL command will run unless the command specified in the unless directive returns 0. -
$mysql_unless
: Specify SQL clause as 'unless' parameter. -
$mysql_onlyif
: Specify SQL clause as 'onlyif' parameter.
Example:
mysql::command { "create MySQL database ${dbname}":
command => "CREATE DATABASE IF NOT EXISTS ${dbname}"
}
See also tests/command.pp
The definition mysql::db
sets up a MySQL database (and eventually the dedidated user associated to it).
This definition accepts the following parameters:
-
$ensure
: Default to 'present', can be 'absent' (BEWARE: it will remove the associated database and ALL its content). -
$creates_user
: Whether or not to create an associated user (that will have the full rights on the database). Note that this user will receive the name of the database, unless the$username
directive is set. -
$username
: Name of the user to be created, default to$name
(in practice, the real MySQL user created will be ${username}@${host}). -
$host
: The host from which this user is assumed to connect from. Default to localhost. -
$password
: Password of the user to be created. If left to an empty string, a random password will be generated (and stored in accessfile). Details of the user (included the password) will be stored in the file/root/.my.cnf
. -
$ro_password
: Password for read-only user. -
$accessfile
: The file used to save the access configuration for the created user. Default to /root/.my_<dbname>.cnf such that later on, you can connect to the mysql client by issuingmysql --defaults-file=/root/.my_<dbname>.cnf
. -
$owner
: Owner of the accessfile. -
$group
: Group owner of the accessfile.
Example:
mysql::db { 'mediawiki':
ensure => 'present',
creates_user => true,
}
See also tests/db.pp
The definition mysql::user
sets up a MySQL user (and stores the associated password in a file).
This definition accepts the following parameters:
-
$ensure
: Default to 'present', can be 'absent'. -
$host
: The host from which this user is assumed to connect from. Default to localhost. -
$password
: Password of the user to be created. If left to an empty string, a random password will be generated (and stored in accessfile). Details of the user (included the password) will be stored in the file <accessfile> (see below). -
$accessfile
: The file used to save the access configuration for the created user. Default to /root/.my_<dbname>.cnf such that later on, you can connect to the mysql client by issuingmysql --defaults-file=/root/.my_<dbname>.cnf
. -
$owner
: Owner of the access file. -
$group
: Group owner of the access file.
Example:
mysql::user { 'mediawiki@localhost':
ensure => 'present',
}
See also tests/user.pp
You can of course configure the mysql module in your Puppetfile
to make it available with Librarian puppet or
r10k by adding the following entry:
# Modules from the Puppet Forge
mod "ULHPC/mysql"
or, if you prefer to work on the git version:
mod "ULHPC/mysql",
:git => 'https://github.com/ULHPC/puppet-mysql',
:ref => 'production'
You can submit bug / issues / feature request using the ULHPC/mysql Puppet Module Tracker.
If you want to contribute to the code, you shall be aware of the way this module is organized.
These elements are detailed on docs/contributing.md
.
You are more than welcome to contribute to its development by sending a pull request.
The best way to test this module in a non-intrusive way is to rely on Vagrant.
The Vagrantfile
at the root of the repository pilot the provisioning various vagrant boxes available on Vagrant cloud you can use to test this module.
See docs/vagrant.md
for more details.
Read the Docs aka RTFD hosts documentation for the open source community and the ULHPC/mysql puppet module has its documentation (see the docs/
directly) hosted on readthedocs.
See docs/rtfd.md
for more details.
This project and the sources proposed within this repository are released under the terms of the GPL-3.0 licence.