---
{%- from "mariadb/map.jinja" import mariadb with context %}
{%- for key, user in mariadb.users.items() %}
mariadb-user-{{ user.name }}:
  mysql_user.present:
    - name: {{ user.name }}
    - password: {{ user.password }}
    - host: '{{ user.host }}'
    - connection_user: {{ mariadb.connection_user }}
    - connection_pass: {{ mariadb.connection_pass }}

{%- for grant in user.grants %}
mariadb-grants-{{ grant.name }}:
  mysql_grants.present:
    - name: {{ grant.name }}
    - grant: '{{ grant.grant }}'
    - database: '{{ grant.database }}'
    - user: '{{ user.name }}'
    - host: '{{ user.host }}'
    - connection_user: {{ mariadb.connection_user }}
    - connection_pass: {{ mariadb.connection_pass }}
{%- endfor %}
{%- endfor %}