2020-05-06 11:11:30 +00:00
|
|
|
---
|
|
|
|
# Needs variables:
|
|
|
|
# - site: dict describing the site install (cf group_vars/all/vars.yml)
|
|
|
|
|
2020-05-07 06:17:17 +00:00
|
|
|
- name: "Create database {{ site.mysql_database }} if inexistent"
|
|
|
|
mysql_db:
|
|
|
|
name: "{{ site.mysql_database }}"
|
|
|
|
state: present
|
|
|
|
# Credentials to log in MySQL
|
|
|
|
login_host: localhost
|
|
|
|
login_user: root
|
|
|
|
login_password: "{{ mysql_root_password }}"
|
|
|
|
|
2020-05-06 11:11:30 +00:00
|
|
|
# MySQL equivalent:
|
|
|
|
# create user <user>@<ip> identified by <pass>;
|
|
|
|
# grant all on <db>.* to <user>@<ip>;
|
|
|
|
- name: "Add database user {{ site.mysql_username }}@{{ site.subnet_site_ip }} and grant all privileges on {{ site.mysql_database }}"
|
|
|
|
mysql_user:
|
|
|
|
# Credentials to log in MySQL
|
|
|
|
login_host: localhost
|
|
|
|
login_user: root
|
|
|
|
login_password: "{{ mysql_root_password }}"
|
|
|
|
# Credentials of the new db user
|
|
|
|
host: "{{ site.subnet_site_ip }}"
|
|
|
|
name: "{{ site.mysql_username }}"
|
|
|
|
password: "{{ site.mysql_password }}"
|
|
|
|
# Grants
|
|
|
|
priv: "{{ site.mysql_database }}.*:all"
|
2020-05-07 06:17:17 +00:00
|
|
|
state: present
|