Commit b8cbc8a0 authored by Xavier Thompson's avatar Xavier Thompson

stack/erp5: Add mariadb user for replication

Use a generated password and publish its url.
parent a1ddc54e
......@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196
[template-mariadb]
filename = instance-mariadb.cfg.in
md5sum = 89793174999fc95f4bc4692c9d4e883e
md5sum = 03a9b5e5e3997d9024bbf72fe7d706ed
[template-kumofs]
filename = instance-kumofs.cfg.in
......@@ -46,7 +46,7 @@ md5sum = 2c553103f1196f95e4b6d0716a1e0638
[template-mariadb-initial-setup]
filename = mariadb_initial_setup.sql.in
md5sum = f928b9dc99f7f970caadfe7dd6f95d34
md5sum = 6562d4cf2325577ab39f8fe2a46d3f1c
[template-postfix]
filename = instance-postfix.cfg.in
......
......@@ -38,6 +38,7 @@ database-list = {{ render_database_list(database_list) }}
test-database-list = {{ render_database_list(test_database_list) }}
monitor-base-url = ${monitor-publish-parameters:monitor-base-url}
replication-bootstrap-url = ${mariadb-backup-static-http-server:bootstrap-url}
replication-primary-url = mysql://replication_user:${replication-password:passwd}@{{ ip_as_host }}:{{ port }}
[publish-early]
recipe = slapos.cookbook:publish-early
......@@ -167,9 +168,14 @@ output = ${directory:etc}/mariadb.cnf
url = {{ parameter_dict['template-my-cnf'] }}
context = section parameter_dict my-cnf-parameters
[replication-password]
recipe = slapos.cookbook:generate.password
storage-path = ${directory:etc}/mariadb-replication.password
[init-script-parameters]
database-list = {{ dumps(database_list + test_database_list) }}
mroonga-mariadb-install-sql = {{ dumps(parameter_dict['mroonga-mariadb-install-sql']) }}
replication-password = ${replication-password:passwd}
[init-script]
recipe = slapos.recipe.template:jinja2
......
......@@ -20,3 +20,8 @@ GRANT PROCESS ON *.* TO `{{ user }}`@localhost IDENTIFIED BY '{{ password }}';
{% for entry in parameter_dict['database-list'] -%}
{{ database(entry['name'], entry.get('user'), entry.get('password'), entry.get('with-process-privilege')) }}
{% endfor -%}
{% set replication_password = parameter_dict.get('replication-password') -%}
{% if replication_password -%}
GRANT REPLICATION SLAVE ON *.* TO `replication_user`@`%` IDENTIFIED BY '{{ replication_password }}';
{%- endif %}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment