Commit 3ebe4aff authored by Alain Takoudjou's avatar Alain Takoudjou

repman: publish slave database list

parent 0596a4ad
...@@ -18,7 +18,7 @@ md5sum = 1812befaf367f30a1fe469ccf95dae31 ...@@ -18,7 +18,7 @@ md5sum = 1812befaf367f30a1fe469ccf95dae31
[instance-repman.cfg] [instance-repman.cfg]
_update_hash_filename_ = instance-repman.cfg.jinja2.in _update_hash_filename_ = instance-repman.cfg.jinja2.in
md5sum = effd642104d1323e0d8a111546331905 md5sum = b65e982e82dbef25cc71c12f91185e03
[config-toml.in] [config-toml.in]
_update_hash_filename_ = templates/config.toml.in _update_hash_filename_ = templates/config.toml.in
......
{
"$schema": "http://json-schema.org/draft-04/schema",
"properties": {
"db_name": {
"description": "Database Name. If empty, name is autogenerated from slave reference.",
"title": "Database Name",
"type": "string",
"default": ""
},
"db_user": {
"description": "Database User",
"title": "Database User",
"type": "string",
"default": "user"
},
"db_password": {
"description": "Database Password. If no password set, a password will be generated",
"title": "Database Password",
"type": "string",
"default": ""
}
},
"title": "Input Parameters",
"type": "object"
}
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
{% set cluster_list = [] -%} {% set cluster_list = [] -%}
{% set tag_list = ["gtidstrict", "bind", "pkg", "innodb", "noquerycache", "slow", "pfs", "linux", "readonly", "diskmonitor", "sqlerror", "compressbinlog", "bm4ci", "mroonga", "utctime", "readcommitted", "nohandshake"] -%} {% set tag_list = ["gtidstrict", "bind", "pkg", "innodb", "noquerycache", "slow", "pfs", "linux", "readonly", "diskmonitor", "sqlerror", "compressbinlog", "bm4ci", "mroonga", "utctime", "readcommitted", "nohandshake"] -%}
{% set frontend_parameter_dict = slapparameter_dict.get('slave-frontend', {}) -%} {% set frontend_parameter_dict = slapparameter_dict.get('slave-frontend', {}) -%}
{% set dabase_slave_list = [] -%}
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
...@@ -58,6 +59,20 @@ template = inline:#!{{ bash_bin }} ...@@ -58,6 +59,20 @@ template = inline:#!{{ bash_bin }}
rendered = ${directory:bin}/update-proxysql-config rendered = ${directory:bin}/update-proxysql-config
mode = 755 mode = 755
{% set db_name_list = [] -%}
[database-slave-information]
{% for instance_dict in slave_instance_list -%}
{% set slave_dict = {
'name': instance_dict.get('db_name', instance_dict['db_name'].replace('-', '_').lower()),
'user': instance_dict.get('db_user', 'user'),
'password': instance_dict.get('db_password'),
'slave_reference': instance_dict['slave_reference']
} -%}
{{ slave_dict['name'] }} = {{ dumps(slave_dict) }}
{% do dabase_slave_list.append(slave_dict) -%}
{% do db_name_list.append(slave_dict['name']) -%}
{% endfor %}
{% do mariadb_dict.__setitem__('computer-memory-percent-threshold', 80) -%} {% do mariadb_dict.__setitem__('computer-memory-percent-threshold', 80) -%}
{% set default_parameter_dict = {"cluster1": {"name": "cluster1", "db-prefered-master": "", {% set default_parameter_dict = {"cluster1": {"name": "cluster1", "db-prefered-master": "",
"database-amount": 2, "proxysql-user": "external", "database-amount": 2, "proxysql-user": "external",
...@@ -78,7 +93,6 @@ mode = 755 ...@@ -78,7 +93,6 @@ mode = 755
{% set section = 'request-mariadb-' ~ i -%} {% set section = 'request-mariadb-' ~ i -%}
{% set dbname = 'Mariadb-' ~ i -%} {% set dbname = 'Mariadb-' ~ i -%}
# {{ dumps(slave_instance_list) }}
[{{ section }}] [{{ section }}]
<= request-common <= request-common
...@@ -97,7 +111,7 @@ config-repman-url = ${nginx-parameter:backend-url} ...@@ -97,7 +111,7 @@ config-repman-url = ${nginx-parameter:backend-url}
config-repman-secure-url = ${nginx-parameter:backend-ssl-url} config-repman-secure-url = ${nginx-parameter:backend-ssl-url}
config-cluster = {{ name }} config-cluster = {{ name }}
config-name = {{ dbname }} config-name = {{ dbname }}
config-database-list = {{ dumps(slave_instance_list) }} config-database-list = {{ dumps(dabase_slave_list) }}
return = return =
database-host database-host
receiver-port receiver-port
...@@ -271,11 +285,6 @@ context = ...@@ -271,11 +285,6 @@ context =
{% do part_list.append(name ~ '-publish-slave-information') -%} {% do part_list.append(name ~ '-publish-slave-information') -%}
{% endfor -%} {% endfor -%}
[database-slave-information]
{% for slave_dict in slave_instance_list -%}
{{ slave_dict['name'] }} = {{ dumps(slave_dict) }}
{% endfor %}
[slap-configuration] [slap-configuration]
recipe = slapos.cookbook:slapconfiguration recipe = slapos.cookbook:slapconfiguration
computer = ${slap-connection:computer-id} computer = ${slap-connection:computer-id}
...@@ -475,12 +484,17 @@ name = nginx ...@@ -475,12 +484,17 @@ name = nginx
log = ${nginx-parameter:access-log} ${nginx-parameter:error-log} log = ${nginx-parameter:access-log} ${nginx-parameter:error-log}
post = kill -USR1 $(cat ${nginx-parameter:pid-file}) post = kill -USR1 $(cat ${nginx-parameter:pid-file})
{% set db_list = db_name_list | join(' ') -%}
[db-slave-requested]
name = {{ db_list }}
[publish-early] [publish-early]
recipe = slapos.cookbook:publish-early recipe = slapos.cookbook:publish-early
-init = -init =
monitor-password monitor-htpasswd:passwd monitor-password monitor-htpasswd:passwd
db-root-password gen-root-password:passwd db-root-password gen-root-password:passwd
repman-password repman-password:passwd repman-password repman-password:passwd
database-list db-slave-requested:name
[publish-connection-parameter] [publish-connection-parameter]
<= monitor-publish <= monitor-publish
...@@ -489,6 +503,7 @@ recipe = slapos.cookbook:publish ...@@ -489,6 +503,7 @@ recipe = slapos.cookbook:publish
backend-url = ${nginx-parameter:backend-ssl-url} backend-url = ${nginx-parameter:backend-ssl-url}
url = ${repman-frontend:connection-secure_access} url = ${repman-frontend:connection-secure_access}
username = ${repman-parameter:username} username = ${repman-parameter:username}
database-list = {{ db_list }}
{% for name, value in publish_dict.items() -%} {% for name, value in publish_dict.items() -%}
{{ name }} = {{ value }} {{ name }} = {{ value }}
{% endfor %} {% endfor %}
......
...@@ -10,6 +10,15 @@ ...@@ -10,6 +10,15 @@
"request": "instance-repman-input-schema.json", "request": "instance-repman-input-schema.json",
"response": "instance-repman-output-schema.json", "response": "instance-repman-output-schema.json",
"index": 0 "index": 0
},
"default-slave": {
"title": "Replication Manager Database",
"description": "Replication Manager Database",
"software-type": "default",
"request": "instance-repman-slave-input-schema.json",
"response": "instance-repman-output-schema.json",
"shared": true,
"index": 1
} }
} }
} }
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