ansible-personal/roles/mariadb/tasks/main.yml
Alan Orth 35d0bee6cf roles/mariadb: Use a template for sources
When you use the apt_repository module it adds a sources.list with
an annoying filename, and also it's just easier to use a template
when we have different distros/versions to support.
2016-04-22 11:25:35 +03:00

55 lines
1.7 KiB
YAML

---
- name: Add GPG key for MariaDB repo
apt_key: id=0xcbcb082a1bb943db url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xcbcb082a1bb943db
tags: mariadb
- name: Add MariaDB 10.1 repo
template: src=mariadb.list.j2 dest=/etc/apt/sources.list.d/mariadb.list owner=root group=root mode=0644
tags: mariadb
- name: Install mariadb-server
apt: name={{ item }} state=present update_cache=yes
with_items:
- mariadb-server
- python-mysqldb # for ansible
tags: mariadb
- 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
- 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
- name: Create WordPress database(s)
mysql_db: db={{ item.wordpress_db_name }} state=present encoding=utf8mb4
with_items: "{{ wordpress_blogs }}"
when: wordpress_blogs is defined
tags: mariadb
- name: Create WordPress user(s)
mysql_user: name={{ item.wordpress_db_user }} password={{ item.wordpress_db_pass }} priv={{ item.wordpress_db_name }}.*:ALL state=present
with_items: "{{ wordpress_blogs }}"
when: wordpress_blogs is defined
tags: mariadb
# vim: set ts=2 sw=2: