2014-08-16 23:35:57 +02:00
|
|
|
---
|
|
|
|
- name: Add GPG key for MariaDB repo
|
2016-08-22 15:06:13 +02:00
|
|
|
apt_key: id=0xF1656F24C74CD1D8 url=https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xF1656F24C74CD1D8
|
2016-08-14 15:33:48 +02:00
|
|
|
tags: mariadb, packages
|
2014-08-16 23:35:57 +02:00
|
|
|
|
2016-04-15 10:42:03 +02:00
|
|
|
- name: Remove old repo file
|
|
|
|
file: path={{ item }} state=absent
|
|
|
|
with_items:
|
|
|
|
- /etc/apt/sources.list.d/sgp1_mirrors_digitalocean_com_mariadb_repo_10_1_debian.list
|
|
|
|
- /etc/apt/sources.list.d/sgp1_mirrors_digitalocean_com_mariadb_repo_10_1_ubuntu.list
|
2016-08-14 15:33:48 +02:00
|
|
|
tags: mariadb, packages
|
2016-04-15 10:42:03 +02:00
|
|
|
|
2015-10-19 22:54:26 +02:00
|
|
|
- name: Add MariaDB 10.1 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
|
2016-08-14 15:33:48 +02:00
|
|
|
tags: mariadb, packages
|
2014-08-16 23:35:57 +02:00
|
|
|
|
|
|
|
- name: Install mariadb-server
|
2016-08-22 14:33:57 +02:00
|
|
|
apt: name={{ item }} state=present update_cache=yes cache_valid_time=3600
|
2014-08-16 23:35:57 +02:00
|
|
|
with_items:
|
|
|
|
- mariadb-server
|
2014-08-27 14:56:54 +02:00
|
|
|
- python-mysqldb # 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
|
|
|
- name: Start and enable MariaDB Service
|
|
|
|
service: name=mysql state=started enabled=true
|
|
|
|
tags: mariadb
|
|
|
|
|
|
|
|
# 'localhost' needs to be the last item for idempotency, see
|
|
|
|
# http://ansible.cc/docs/modules.html#mysql-user
|
|
|
|
- name: Update MariaDB root password for all root accounts
|
|
|
|
mysql_user: name=root host={{ item }} password={{ mariadb_root_password }}
|
|
|
|
with_items:
|
|
|
|
- "{{ 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
|
|
|
|
with_items: "{{ mariadb_databases }}"
|
|
|
|
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
|
|
|
|
with_items: "{{ mariadb_databases }}"
|
|
|
|
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:
|