Skip to content

Commit

Permalink
File /etc/my.cnf is standard in mariadb
Browse files Browse the repository at this point in the history
- Don't anticipate the users to change it, so removing the option.
- Add the config_file param to other tasks using ansible modules.

For reference, the workaround with config_file is needed due to a change in
mysql libs used by ansible (see ansible/ansible#47736)
  • Loading branch information
luisico committed Jun 27, 2019
1 parent 0b67454 commit 705a2eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions defaults/main.yml
Expand Up @@ -37,9 +37,6 @@ mysql_secure: true
# Root password
mysql_root_password: mysql

# location of config_file
mysql_config_file: /etc/my.cnf

# Backup (deactivated by default)
# Default user password and contact email use the local 'mysqlbck' acocunt
mysql_backup: false
Expand Down
10 changes: 5 additions & 5 deletions tasks/main.yml
Expand Up @@ -69,7 +69,7 @@

- block:
- name: Secure installation
mysql_user: name=root host={{item}} check_implicit_admin=yes password='{{mysql_root_password}}' login_user=root login_password='{{mysql_root_password}}' config_file={{mysql_config_file}}
mysql_user: name=root host={{item}} check_implicit_admin=yes password='{{mysql_root_password}}' login_user=root login_password='{{mysql_root_password}}' config_file=/etc/my.cnf
with_items:
- '{{ansible_fqdn | lower}}'
- '{{ansible_hostname | lower}}'
Expand All @@ -79,28 +79,28 @@
when: mysql_root_password != ''

- name: Remove anonymous users
mysql_user: name='' host={{item}} state=absent login_user=root login_password='{{mysql_root_password}}' config_file={{mysql_config_file}}
mysql_user: name='' host={{item}} state=absent login_user=root login_password='{{mysql_root_password}}' config_file=/etc/my.cnf
with_items:
- '{{ansible_hostname | lower}}'
- '{{ansible_fqdn | lower}}'
- localhost

- name: Remove test database
mysql_db: name=test state=absent login_user=root login_password='{{mysql_root_password}}' config_file={{mysql_config_file}}
mysql_db: name=test state=absent login_user=root login_password='{{mysql_root_password}}' config_file=/etc/my.cnf

when: mysql_secure

- import_tasks: encryption.yml
when: mysql_encryption_enabled and mysql_encryption_key_plugin == 'file'

- name: Add databases
mysql_db: name={{item.name}} state=present login_user=root login_password='{{mysql_root_password}}'
mysql_db: name={{item.name}} state=present login_user=root login_password='{{mysql_root_password}}' config_file=/etc/my.cnf
with_items: '{{mysql_databases}}'
loop_control:
label: '{{item | combine({"password": "***"})}}'

- name: Add users
mysql_user: name={{item.0.user}} host={{item.1}} password='{{item.0.password}}' priv='{{item.0.name}}.*:{{item.0.privileges | default("ALL")}}' state=present login_user=root login_password='{{mysql_root_password}}' append_privs='{{mysql_append_privs}}'
mysql_user: name={{item.0.user}} host={{item.1}} password='{{item.0.password}}' priv='{{item.0.name}}.*:{{item.0.privileges | default("ALL")}}' state=present login_user=root login_password='{{mysql_root_password}}' append_privs='{{mysql_append_privs}}' config_file=/etc/my.cnf
with_subelements:
- '{{mysql_databases}}'
- hosts
Expand Down

0 comments on commit 705a2eb

Please sign in to comment.