ansible-roles/mysql/tasks/manage_my_db.yml

15 lines
590 B
YAML
Raw Normal View History

---
- name: Add databases to mysql, if any
mysql_db: name={{ item.name }} collation={{ item.collation }} encoding={{ item.encoding }} state=present
with_items: '{{ mysql_db_data | default([]) }}'
when: item.name is defined
tags: [ 'mysql', 'mysql_db' ]
- name: Add a user for the databases
mysql_user: name={{ item.0.user }} password={{ item.0.pwd }} host={{ item.1 }} priv="{{ item.0.name }}.*:{{ item.0.user_grant }}" state=present
with_subelements:
- '{{ mysql_db_data | default([]) }}'
- allowed_hosts
when: item.0.name is defined
tags: [ 'mysql', 'mysql_db' ]