automation/deployer/roles/build/tasks/mysql.yml
2020-05-07 08:17:17 +02:00

29 lines
No EOL
976 B
YAML

---
# Needs variables:
# - site: dict describing the site install (cf group_vars/all/vars.yml)
- 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 }}"
# 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"
state: present