mariadb-database-exists

Example:

# Install MariaDB and create a MySQL database and user with full access to it.
- mariadb-database-exists:
    db_name: my_database
    db_user: freckles
    db_password: password123

Description

Installs MariaDB service on a host, and ensures a database with the provided name is present.

If a database dump file is provided, the database will be imported from it. Otherwise an empty table will be created.

If a database dump file is provided, the database name can also be 'all', in which case all databases contained in it will be imported.

If a username is supplied, but no db_user_priv, the user 'db_name.*:ALL' privileges granted.

Resources

Variables

Name Type Default Description

db_name

string --

The name of the database to use from the dump (or 'all'). Required

db_dump_file

string --

An (optional) database dump file.

db_host

string --

The 'host' part of the MySQL username.

db_import

boolean False

Whether to use a sql dump file to create the database.

db_user

string --

The name of the database user.

db_user_password

string --

The password for the database user.

db_user_priv

string --

The user privileges.

mysql_group_id

integer --

An (optional) custom mysql group id

mysql_user_id

integer --

An (optional) custom mysql user id

Examples

Example 1

Install MariaDB and create a MySQL database and user with full access to it.

Code
- mariadb-database-exists:
    db_name: my_database
    db_user: freckles
    db_password: password123
Description

Be aware, that if you do it like this the user password is used in plain text, which could be a security issue. Please check the freckles security documentation for details and options.

Command-line

frecklecute mariadb-database-exists --help

Usage: frecklecute mariadb-database-exists [OPTIONS]

  Installs MariaDB service on a host, and ensures a database with the
  provided name is present.

  If a database dump file is provided, the database will be imported from
  it. Otherwise an empty table will be created.

  If a database dump file is provided, the database name can also be 'all',
  in which case all databases contained in it will be imported.

  If a username is supplied, but no ``db_user_priv``, the user
  'db_name.*:ALL' privileges granted.

Options:
  --db-name DB_NAME               The name of the database to use from the
                                  dump (or 'all').  [required]
  --db-dump-file DB_DUMP_FILE     An (optional) database dump file.
  --db-host DB_HOST               The 'host' part of the MySQL username.
  --db-import / --no-db-import    Whether to use a sql dump file to create the
                                  database.
  --db-user DB_USER               The name of the database user.
  --db-user-password DB_USER_PASSWORD
                                  The password for the database user.
  --db-user-priv DB_USER_PRIV     The user privileges.
  --mysql-group-id MYSQL_GROUP_ID
                                  An (optional) custom mysql group id
  --mysql-user-id MYSQL_USER_ID   An (optional) custom mysql user id
  --help                          Show this message and exit.