Skip to content

Commit

Permalink
Parametrize mysql privileges and group options
Browse files Browse the repository at this point in the history
  • Loading branch information
vamgnu authored and Daniel Viñar Ulriksen committed Sep 12, 2024
1 parent c8eac97 commit cfba5d9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ The following variables give some tools to define, using hereabove described scr
Passwords setup and privileges of this user on the database must be set elsewhere in the playbook.
- For Mysql, variables are:
- `backuppc_db_server_root_pass` should be set to the appropriate value, if the mysql `root` user has a password defined. By default, the variable is undefined. It must be noticed that, in recent mysql/mariadb installation, at least on Debian, installation doesn't ask for and doesn't ramdomly generate a root password. Debian maintainance is no longer done with a specific user and password, but with user root through a unix sock and not a tcp authenticated sock. If the variable remains undefined, mysql tasks will be performed using debian maintenance configuration.
- `backuppc_db_dump_user` and `backuppc_db_dump_user_pass` are the name of the mysql user and the correspondent password, that will be given SELECT access to all databases and will be configured as default in the `.my.cnf` file in the home directory of the `backuppc_client_user` unix user, to alow access from the linux user that executes the backup scripts. Therefore `pre_dump.sh` or `post_dump.sh` scripts will be able to perform any database dump calling a simple mysql command, without specifiyng user or password.
- `backuppc_db_dump_user` and `backuppc_db_dump_user_pass` are the names of the mysql user and the correspondent password, that will be given SELECT access to all databases and will be configured as default in the `.my.cnf` file in the home directory of the `backuppc_client_user` unix user, to allow access from the linux user that executes the backup scripts. Therefore `pre_dump.sh` or `post_dump.sh` scripts will be able to perform any database dump calling a simple mysql command, without specifiyng user or password.
- `backuppc_db_dump_user_priv` are the privileges for `backuppc_db_dump_user` to perform backups. For example: `'*.*:PROCESS,SUPER,SELECT` or `*.*:RELOAD,PROCESS,LOCK TABLES,REPLICATION CLIENT`.
- `backuppc_db_dump_group_options` are the specific group options mariadb/mysql tools. For example: `client` (default) or `mariabackup`.

#### Mysql script examples

Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ backuppc_db_server_type: ''
backuppc_db_dump_user: "{{ backuppc_client_user }}"
backuppc_db_dump_user_pass: 'put_it_from_a_vault'
backuppc_db_to_dump_name: 'my_app'
backuppc_db_dump_user_priv: '*.*:PROCESS,SUPER,SELECT'
backuppc_db_dump_group_options: "client"

## BackupPC web interface

Expand Down
2 changes: 1 addition & 1 deletion tasks/mysql_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
user: "{{ backuppc_db_dump_user }}"
password: "{{ backuppc_db_dump_user_pass }}"
state: present
priv: '*.*:PROCESS,SUPER,SELECT'
priv: "{{ backuppc_db_dump_user_priv }}"
config_file: "{{ omit if backuppc_db_server_root_pass is defined else backuppc_mysql_credentials_file[(ansible_os_family|lower)] | default(omit) }}"


Expand Down
2 changes: 1 addition & 1 deletion templates/etc/mysql/.my.cnf.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[client]
[{{ backuppc_db_dump_group_options }}]
user={{ backuppc_db_dump_user }}
password={{ backuppc_db_dump_user_pass }}

0 comments on commit cfba5d9

Please sign in to comment.