Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Tyagov
slapos
Commits
3121bdee
Commit
3121bdee
authored
Jul 12, 2021
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repman: generate slave database password if not set
parent
33d3246a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
29 deletions
+26
-29
software/repman/buildout.hash.cfg
software/repman/buildout.hash.cfg
+3
-3
software/repman/instance-mariadb.cfg.jinja2.in
software/repman/instance-mariadb.cfg.jinja2.in
+0
-7
software/repman/instance-repman-slave-input-schema.json
software/repman/instance-repman-slave-input-schema.json
+4
-10
software/repman/instance-repman.cfg.jinja2.in
software/repman/instance-repman.cfg.jinja2.in
+17
-7
software/repman/publish-database-slave-parameters.cfg.in
software/repman/publish-database-slave-parameters.cfg.in
+2
-2
No files found.
software/repman/buildout.hash.cfg
View file @
3121bdee
...
...
@@ -18,7 +18,7 @@ md5sum = 9aeb37bd4590aa7fa746ef70d78cc0d0
[instance-repman.cfg]
_update_hash_filename_ = instance-repman.cfg.jinja2.in
md5sum =
8e4fcaf0e76a1b8a799c671dd3ad2de9
md5sum =
4338ea29fcdae38393eb52d8d2bf66d1
[config-toml.in]
_update_hash_filename_ = templates/config.toml.in
...
...
@@ -34,7 +34,7 @@ md5sum = 0eeb24c6aa0760f0d33c4cc2828ddf30
[template-mariadb.cfg]
_update_hash_filename_ = instance-mariadb.cfg.jinja2.in
md5sum =
b1344ec1c0ccd4670a87cea18b0aed53
md5sum =
6af0fb36ebdc5f1730ed3a9319eafdad
[template-my-cnf]
_update_hash_filename_ = templates/my.cnf.in
...
...
@@ -46,7 +46,7 @@ md5sum = 96c151c376600a90fe2a44825f2de550
[template-publish-slave-information]
_update_hash_filename_ = publish-database-slave-parameters.cfg.in
md5sum =
ea35caa846702c71cd353e81c766befb
md5sum =
9616477ff993c55c2b43bf8797db6994
[mariadb-init-root-sql]
_update_hash_filename_ = templates/mariadb_init_root.sql.in
...
...
software/repman/instance-mariadb.cfg.jinja2.in
View file @
3121bdee
...
...
@@ -17,18 +17,11 @@
[{{ section('publish') }}]
recipe = slapos.cookbook:publish.serialised
-extends = publish-early
database-host = {{ host }}:{{ port }}
monitor-base-url = ${monitor-publish-parameters:monitor-base-url}
partition-path = ${buildout:directory}
receiver-port = ${dbjob-parameter:socat-port}
[publish-early]
recipe = slapos.cookbook:publish-early
-init =
database-list = {{ dumps(database_list) }}
[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
mode = 644
...
...
software/repman/instance-repman-slave-input-schema.json
View file @
3121bdee
{
"$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"
,
"description"
:
"Database User
, default is 'user'. This parameter is set only if database is not created yet.
"
,
"title"
:
"Database User"
,
"type"
:
"string"
,
"default"
:
"user"
},
"db_password"
:
{
"description"
:
"Database
Password. If no password set, a password will be generated
"
,
"title"
:
"
Database P
assword"
,
"description"
:
"Database
password. If no password set, a password will be generated. This parameter is set only if database is not created yet.
"
,
"title"
:
"
Initial database p
assword"
,
"type"
:
"string"
,
"default"
:
""
},
"db_charset"
:
{
"description"
:
"Database Character set information."
,
"description"
:
"Database Character set information.
This parameter is set only if database is not created yet.
"
,
"title"
:
"Database Character set information"
,
"type"
:
"string"
,
"enum"
:
[
...
...
software/repman/instance-repman.cfg.jinja2.in
View file @
3121bdee
...
...
@@ -10,9 +10,16 @@
{% set cluster_list = [] -%}
{% 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 dabase_slave_list = [] -%}
{% set da
ta
base_slave_list = [] -%}
{% set db_name_list = [] -%}
{% macro password(name) -%}
[{{ name }}-password]
recipe = slapos.cookbook:generate.password
bytes = 12
{% endmacro -%}
[directory]
recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}
...
...
@@ -60,18 +67,21 @@ template = inline:#!{{ bash_bin }}
rendered = ${directory:bin}/update-proxysql-config
mode = 755
[database-slave-information]
{% for instance_dict in slave_instance_list -%}
{% set slave_dict = {
'name': 'db_%s' % instance_dict['slave_reference'].replace('-', '_').lower(),
'user': instance_dict.get('db_user', 'user'),
'password': instance_dict.get('db_password'),
'password': instance_dict.get('db_password'
, '${' ~ instance_dict['slave_reference'] ~ '-password:passwd}'
),
'slave_reference': instance_dict['slave_reference'],
'charset': instance_dict.get('db_charset', '')
} -%}
{{ slave_dict['name'] }} = {{ dumps(slave_dict) }}
{% do dabase_slave_list.append(slave_dict) -%}
{% do database_slave_list.append(slave_dict) -%}
{% do db_name_list.append(slave_dict['name']) -%}
{{ password(instance_dict['slave_reference']) }}
{% endfor %}
[database-slave-information]
{% for slave_dict in database_slave_list -%}
{{ slave_dict['name'] }} = !py!{{ slave_dict }}
{% endfor %}
{% set db_list = db_name_list | join(' ') -%}
...
...
@@ -93,7 +103,7 @@ mode = 755
{% for i in range(0, db_amount) -%}
{% do mariadb_dict.__setitem__('tcp-port', 2099 + (i * 100)) -%}
{% set section = 'request-mariadb-' ~ i -%}
{% set dbname = 'Mariadb-' ~ i
-
%}
{% set dbname = 'Mariadb-' ~ i %}
[{{ section }}]
...
...
@@ -113,7 +123,7 @@ config-repman-url = ${nginx-parameter:backend-url}
config-repman-secure-url = ${nginx-parameter:backend-ssl-url}
config-cluster = {{ name }}
config-name = {{ dbname }}
config-database-list =
{{ dumps(dabase_slave_list)
}}
config-database-list =
!py!{{ database_slave_list
}}
config-database-name = {{ dumps(db_list) }}
return =
database-host
...
...
software/repman/publish-database-slave-parameters.cfg.in
View file @
3121bdee
...
...
@@ -32,6 +32,6 @@ develop-eggs-directory = {{ develop_eggs_directory }}
offline = true
parts =
{% for part in part_list %}
{% for part in part_list
-
%}
{{ ' %s' % part }}
{% endfor %}
{% endfor
-
%}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment