dataset/seed/mariadb/templates/mariadb.sql

14 lines
928 B
SQL

{% set new_accounts = [('_gateway', 'rougail_test', 'rougail_test', 'rougail_test'|get_password(server_name=domain_name_eth0, description="remote", type="cleartext", hide=hide_secret, temporary=True))] %}
{% for server in accounts.remotes %}
{% set name = server|normalize_family %}
{% set database = accounts["remote_" + name]["database_" + name] %}
{% set username = accounts["remote_" + name]["username_" + name] %}
{% set password = accounts["remote_" + name]["password_" + name] %}
{{ new_accounts.append((server|string, database, username, password)) }}
{% endfor %}
{% for server, database, username, password in new_accounts %}
CREATE USER IF NOT EXISTS '{{ database}}'@'{{ server }}' IDENTIFIED BY '{{ password }}';
CREATE DATABASE IF NOT EXISTS {{ database }} CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON {{ username }}.* TO '{{ database }}'@'{{ server }}' IDENTIFIED BY '{{password }}';
{% endfor %}
FLUSH PRIVILEGES;