2014-08-16 23:35:57 +02:00
|
|
|
---
|
|
|
|
- name: Add GPG key for MariaDB repo
|
2016-08-22 15:30:20 +02:00
|
|
|
apt_key: id=0x177F4010FE56CA3336300305F1656F24C74CD1D8 url=https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x177F4010FE56CA3336300305F1656F24C74CD1D8
|
2019-03-17 16:29:15 +01:00
|
|
|
register: add_mariadb_apt_key
|
2016-08-14 15:33:48 +02:00
|
|
|
tags: mariadb, packages
|
2014-08-16 23:35:57 +02:00
|
|
|
|
2019-07-05 19:39:17 +02:00
|
|
|
- name: Add MariaDB 10.4 repo
|
2016-04-15 10:40:32 +02:00
|
|
|
template: src=mariadb.list.j2 dest=/etc/apt/sources.list.d/mariadb.list owner=root group=root mode=0644
|
2019-03-17 16:29:15 +01:00
|
|
|
register: add_mariadb_apt_repository
|
2016-08-14 15:33:48 +02:00
|
|
|
tags: mariadb, packages
|
2014-08-16 23:35:57 +02:00
|
|
|
|
2019-03-17 16:29:15 +01:00
|
|
|
- name: Update apt cache
|
|
|
|
apt:
|
|
|
|
update_cache: yes
|
|
|
|
when:
|
|
|
|
add_mariadb_apt_key is changed or
|
|
|
|
add_mariadb_apt_repository is changed
|
|
|
|
|
2014-08-16 23:35:57 +02:00
|
|
|
- name: Install mariadb-server
|
2019-03-17 16:29:28 +01:00
|
|
|
apt: name={{ item }} state=present cache_valid_time=3600
|
2018-04-02 14:52:51 +02:00
|
|
|
loop:
|
2014-08-16 23:35:57 +02:00
|
|
|
- mariadb-server
|
2019-05-08 08:15:27 +02:00
|
|
|
- python3-pymysql # for ansible
|
2016-08-14 15:33:48 +02:00
|
|
|
tags: mariadb, packages
|
2014-08-16 23:35:57 +02:00
|
|
|
|
2016-04-22 09:08:32 +02:00
|
|
|
- name: Create system my.cnf
|
|
|
|
template: src=my.cnf.j2 dest=/etc/mysql/my.cnf owner=root group=root mode=0644
|
|
|
|
notify:
|
|
|
|
- restart mysql
|
|
|
|
tags: mariadb
|
|
|
|
|
2014-08-16 23:35:57 +02:00
|
|
|
# 'localhost' needs to be the last item for idempotency, see
|
2017-11-04 23:26:32 +01:00
|
|
|
# https://docs.ansible.com/ansible/latest/mysql_user_module.html
|
2014-08-16 23:35:57 +02:00
|
|
|
- name: Update MariaDB root password for all root accounts
|
|
|
|
mysql_user: name=root host={{ item }} password={{ mariadb_root_password }}
|
2018-04-02 14:52:51 +02:00
|
|
|
loop:
|
2014-08-16 23:35:57 +02:00
|
|
|
- "{{ inventory_hostname }}"
|
|
|
|
- 127.0.0.1
|
|
|
|
- ::1
|
|
|
|
- localhost
|
|
|
|
tags: mariadb
|
|
|
|
|
|
|
|
- name: Create .my.conf file with root credentials
|
|
|
|
template: src=.my.cnf.j2 dest=/root/.my.cnf owner=root mode=0600
|
|
|
|
tags: mariadb
|
|
|
|
|
2016-06-27 17:08:02 +02:00
|
|
|
- name: Create MariaDB database(s)
|
|
|
|
mysql_db: db={{ item.name }} state=present encoding=utf8mb4
|
2018-04-02 14:52:51 +02:00
|
|
|
loop: "{{ mariadb_databases }}"
|
2016-06-27 17:08:02 +02:00
|
|
|
when: mariadb_databases is defined
|
2014-08-28 11:47:30 +02:00
|
|
|
tags: mariadb
|
|
|
|
|
2016-06-27 17:08:02 +02:00
|
|
|
- name: Create MariaDB user(s)
|
|
|
|
mysql_user: name={{ item.user }} password={{ item.pass }} priv={{ item.name }}.*:ALL state=present
|
2018-04-02 14:52:51 +02:00
|
|
|
loop: "{{ mariadb_databases }}"
|
2016-06-27 17:08:02 +02:00
|
|
|
when: mariadb_databases is defined
|
2014-08-28 11:47:30 +02:00
|
|
|
tags: mariadb
|
|
|
|
|
2014-08-16 23:35:57 +02:00
|
|
|
# vim: set ts=2 sw=2:
|