Files
@ 2381ba93d089
Branch filter:
Location: majic-ansible-roles/roles/database_server/tasks/main.yml - annotation
2381ba93d089
2.8 KiB
text/x-yaml
MAR-148: Better workaround for https://github.com/ansible/ansible/issues/64560 (override the module_utils/mysql.py instead of the module itself).
09625826d96f 09625826d96f 09625826d96f 0ffaf31692ce a20ca43cd967 a20ca43cd967 a20ca43cd967 a20ca43cd967 91b633aba998 09625826d96f a561d73e3242 a561d73e3242 a561d73e3242 fcf5abdd3ad5 a561d73e3242 09625826d96f 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 09625826d96f 09625826d96f 0ffaf31692ce 91b633aba998 0ffaf31692ce 0ffaf31692ce 09625826d96f 09625826d96f 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 09625826d96f 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 fcf5abdd3ad5 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 30d5b3fa5b93 19b15357124a 19b15357124a 0ffaf31692ce 0ffaf31692ce 0ffaf31692ce 30d5b3fa5b93 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 7387caca37f3 7387caca37f3 7387caca37f3 fcf5abdd3ad5 7387caca37f3 18f93a9a8b05 | ---
- name: Install MariaDB
apt:
name:
- mariadb-client
- mariadb-server
- python-mysqldb
state: present
- name: Enable MariaDB service on boot (workaround for systemctl broken handling of SysV)
command: rcconf -on mysql
register: result
changed_when: not result.stderr
- name: Enable and start MariaDB
service:
name: mysql
state: started
- name: Set password for the root database user
mysql_user:
check_implicit_admin: true
name: root
password: "{{ db_root_password }}"
- name: Deploy username and password for the root database user
template:
src: "root_my.cnf.j2"
dest: "/root/.my.cnf"
owner: root
group: root
mode: 0400
- name: Check if root user authentication is based on use of unix_socket module (Stretch default)
command: mysql --skip-column-names -B -e "select 1 from mysql.user where user='root' and plugin='unix_socket';"
when: "ansible_distribution_release == 'stretch'"
register: "root_using_unix_socket_authentication"
changed_when: false
- name: Disable use of unix socket login on Debian Stretch (temporary workaround)
command: "mysql -B -e \"update mysql.user set plugin='' where user='root' and plugin='unix_socket'; flush privileges;\""
when: "ansible_distribution_release == 'stretch' and root_using_unix_socket_authentication.stdout"
- name: Remove UTF-8 encoding configuration file from the old location on Debian Stretch
file:
path: "/etc/mysql/conf.d/utf8.cnf"
state: absent
when: "ansible_distribution_release == 'stretch'"
register: mariadb_utf8_configuration_stretch
- name: Set UTF-8 encoding as default for MariaDB (on Jessie)
copy:
src: "utf8.cnf"
dest: "/etc/mysql/conf.d/utf8.cnf"
owner: root
group: root
mode: 0644
when: "ansible_distribution_release == 'jessie'"
register: mariadb_utf8_configuration_jessie
- name: Set UTF-8 encoding as default for MariaDB (on Stretch)
copy:
src: "utf8.cnf"
dest: "/etc/mysql/mariadb.conf.d/90-utf8.cnf"
owner: root
group: root
mode: 0644
when: "ansible_distribution_release == 'stretch'"
register: mariadb_utf8_configuration_stretch
- name: Restart MariaDB in order to use UTF-8 as default character set
service:
name: mysql
state: restarted
when: mariadb_utf8_configuration_jessie.changed or mariadb_utf8_configuration_stretch.changed
tags:
# [ANSIBLE0016] Tasks that run when changed should likely be handlers
# UTF-8 configuration must be applied immediatelly in order to ensure that
# subsequent tasks that create databases will end-up with correct (UTF-8)
# encoding. Otherwise they will be created using default latin1.
- skip_ansible_lint
- name: Explicitly run all handlers
include: ../handlers/main.yml
when: "run_handlers | default(False) | bool()"
tags:
- handlers
|