Default variable details¶
Some of debops.mariadb default variables have more extensive configuration than simple strings or lists, here you can find documentation and examples for them.
List of databases that should be present or absent on a given MariaDB server. Each database is defined as a YAML dict with the following keys:
- Name of the database, required. Should be composed from alphanumeric
characters and underscore (
_) only. Max length: 16 for MySQL databases, 80 for MariaDB databases.
- Optional. If value is
present, database will be created; if
absent, database will be removed.
- Optional. Path to a file with SQL dump on the Ansible Controller, which will
be copied to the remote host at the
targetlocation, imported into database (only if it was recently created), and removed afterwards. The role does not check if the file exists before copying it, so make sure that it's present in the location that you specify beforehand.
- Optional. Path to a file on the remote host which will be imported to the
database after it has been created (only once). The role does not check if the
file exists before trying to import it. You can use the
sourceparameter to specify a file on the Ansible Controller to copy to the
targetlocation before import.
- Optional. If present and
False, it will prevent deletion of target file on remote host.
Create databases, remove some of the existing ones:
mariadb__databases: - name: 'database1' - name: 'database2' - name: 'old_database' state: 'absent'
Create a database and import its contents from a file already present on remote host:
mariadb__databases: - name: 'fancy_db' target: '/tmp/dbcontents.sql.gz'
Create a database and import its contents from a file on the Ansible Controller:
mariadb__databases: - name: 'new_database' source: '/tmp/database-contents.sql.gz' target: '/tmp/dbcontents.sql.gz'
List of user accounts that should be present or absent on a given MariaDB server. Each user account is defined as a dict with a set of keys and values.
User account parameters¶
- Required. The "username" part of the user account on the MariaDB server. If
nameis specified, it will be used to determine the database name for granting default privileges, if
databaseis not specified.
- Optional. The "hostname" part of the user account on the MariaDB server. If not specified, it will be generated automatically by the role (this is usually what you want). It specifies the hostname or IP address of the host that is allowed to connect to the database.
- Optional. If specified, the role will set it as the password for the MariaDB
account. If not present, a random password will be generated automatically
and stored in the
secret/directory on the Ansible Controller. Refer to the debops.secret role for more details.
- Optional. If
present, the account will be created on the database server. If
absent, account will be removed from the database server.
- Optional. If present, it specifies the database name and/or database prefix
that a given user account will be able to access using default privileges. If
namewill be used instead.
- Optional. By default, the user accounts will get all privileges to databases with
the same name. If this key is present and
False, the users will not get default privileges.
- Optional. By default, the user accounts will get all privileges to the database
prefixed with the name of the user account. If this key is present and
False, the users will not get default prefix privileges.
- Optional. String or list of privileges to grant to a given user account. See
mysql_userdocumentation for information about how to specify the privileges.
- Optional. If present and
True, specified privileges will be appended to already existing privileges (default). If
False, specified privileges will replace all current privileges for a given user account.
User configuration file¶
- Optional. It should specify a local UNIX account on the host managed by
the debops.mariadb role (not on the host with the database, unless it's
a local installation). If specified, the debops.mariadb role will create
a local UNIX account if it doesn't exist with the specified name and create
~/.my.cnfconfiguration file with the MariaDB account credentials and configuration pointing to the MariaDB server.
- Optional. Main local UNIX group of the created account. If not specified, a group named after the account will be created instead.
- Required if
item.owneris specified. Specifies the home directory of given local UNIX account.
- Optional. If specified and
True, the local UNIX group/user account which is going to be created will be a "system" account with UID/GID < 1000. If specified and
False, local UNIX group/user account will be a "normal" account with UID/GID >= 1000. By default groups and accounts will be created as "system" accounts.
- Optional. If specified, defines the permissions of the
~/.my.cnfconfiguration file. By default they are set to
- Optional, string. Allows you to change the file path for the credentials file
which defaults to
Create a MariaDB user account with all privileges granted to the
mariadb__users: - name: 'someuser'
Create a MariaDB user account with all privileges to
without auxiliary privileges:
mariadb__users: - name: 'someuser' database: 'somedatabase' priv_aux: False
Create a MariaDB user account and set up a local system account configured to use MariaDB:
mariadb__users: - name: 'someuser' owner: 'system-user' home: '/var/local/system-user'
Create a MariaDB user account without default privileges:
mariadb__users: - name: 'someuser' priv_default: False priv_aux: False
Create a MariaDB user account with custom additional privileges:
mariadb__users: - name: 'someuser' priv: [ 'otherdb.*:ALL' ]
The role uses
/etc/mysql/conf.d/client.cnf configuration file to manage the
MariaDB/MySQL system-wide client configuration. This configuration file is
generated by a template that uses the
to get the configuration data. The configuration itself is split among several
variables located in
A minimal configuration is stored as a YAML dictionary. Keys of the dictionary as MariaDB configuration option names, and values of the dictionary are the configuration values. All values are automatically quoted in the generated configuration file.
Example configuration section:
mariadb__options: 'query_cache_type': '0' 'key_buffer': '16M' 'skip_name_resolve':
The dictionary keys without values will be written in the configuration file with correct notation.
Alternative configuration notation is to use a YAML list, each element of a list being a YAML dictionary in the above format. An example:
mariadb__options: - 'query_cache_type': '0' 'key_buffer': '16M' - 'skip_name_resolve':
Yet another alternative format can be used if you use certain keys in the YAML
dictionary. The template checks for presence of the
keys, and if found, changes to a different format that uses YAML dictionary
- Required for the main options. Name of the option to add.
- Required for the definiton of a configuration section. Create new section of the configuration file, written in square brackets.
- Optional. Either
absent. If not specified or
present, a given section or option will be added in the configuration file; if
absent, option or section won't be added.
- Optional. Add a comment to a given option or section.
- Optional for main options. If specified, set a value of a given option.
- Optional. A YAML dictionary or list of YAML dictionaries with options to
include in a given section, or multiple options specified together as
a group. If it's specified, values of
mariadb__options: - section: 'client' comment: 'Global MariaDB client options' options: - name: 'skip_name_resolve' - name: 'key_buffer' value: '16M' - name: 'query_cache_type' value: '0' state: 'present'