Commit 2ccafe84 authored by Xavier Thompson's avatar Xavier Thompson

stack/erp5: Add mariadb user for replication

Use a generated password and publish its url.
parent 65415875
...@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196 ...@@ -26,7 +26,7 @@ md5sum = d10b8e35b02b5391cf46bf0c7dbb1196
[template-mariadb] [template-mariadb]
filename = instance-mariadb.cfg.in filename = instance-mariadb.cfg.in
md5sum = 38210ddc120cea1bd5cc78940ac3caf1 md5sum = 3f7ed9f418ad9288c4189487f57120bf
[template-kumofs] [template-kumofs]
filename = instance-kumofs.cfg.in filename = instance-kumofs.cfg.in
...@@ -46,7 +46,7 @@ md5sum = 2c553103f1196f95e4b6d0716a1e0638 ...@@ -46,7 +46,7 @@ md5sum = 2c553103f1196f95e4b6d0716a1e0638
[template-mariadb-initial-setup] [template-mariadb-initial-setup]
filename = mariadb_initial_setup.sql.in filename = mariadb_initial_setup.sql.in
md5sum = f928b9dc99f7f970caadfe7dd6f95d34 md5sum = 6562d4cf2325577ab39f8fe2a46d3f1c
[template-postfix] [template-postfix]
filename = instance-postfix.cfg.in filename = instance-postfix.cfg.in
......
...@@ -38,6 +38,7 @@ database-list = {{ render_database_list(database_list) }} ...@@ -38,6 +38,7 @@ database-list = {{ render_database_list(database_list) }}
test-database-list = {{ render_database_list(test_database_list) }} test-database-list = {{ render_database_list(test_database_list) }}
monitor-base-url = ${monitor-publish-parameters:monitor-base-url} monitor-base-url = ${monitor-publish-parameters:monitor-base-url}
replication-bootstrap-url = ${mariadb-backup-static-http-server:bootstrap-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] [publish-early]
recipe = slapos.cookbook:publish-early recipe = slapos.cookbook:publish-early
...@@ -168,9 +169,14 @@ output = ${directory:etc}/mariadb.cnf ...@@ -168,9 +169,14 @@ output = ${directory:etc}/mariadb.cnf
url = {{ parameter_dict['template-my-cnf'] }} url = {{ parameter_dict['template-my-cnf'] }}
context = section parameter_dict my-cnf-parameters context = section parameter_dict my-cnf-parameters
[replication-password]
recipe = slapos.cookbook:generate.password
storage-path = ${directory:etc}/mariadb-replication.password
[init-script-parameters] [init-script-parameters]
database-list = {{ dumps(database_list + test_database_list) }} database-list = {{ dumps(database_list + test_database_list) }}
mroonga-mariadb-install-sql = {{ dumps(parameter_dict['mroonga-mariadb-install-sql']) }} mroonga-mariadb-install-sql = {{ dumps(parameter_dict['mroonga-mariadb-install-sql']) }}
replication-password = ${replication-password:passwd}
[init-script] [init-script]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
......
...@@ -20,3 +20,8 @@ GRANT PROCESS ON *.* TO `{{ user }}`@localhost IDENTIFIED BY '{{ password }}'; ...@@ -20,3 +20,8 @@ GRANT PROCESS ON *.* TO `{{ user }}`@localhost IDENTIFIED BY '{{ password }}';
{% for entry in parameter_dict['database-list'] -%} {% for entry in parameter_dict['database-list'] -%}
{{ database(entry['name'], entry.get('user'), entry.get('password'), entry.get('with-process-privilege')) }} {{ database(entry['name'], entry.get('user'), entry.get('password'), entry.get('with-process-privilege')) }}
{% endfor -%} {% 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