Commit 41952d9c authored by Andrey Vertiprahov's avatar Andrey Vertiprahov

Merge branch 'fix-032' into 'master'

Fix 032 migration

See merge request !19
parents 9b436817 261637cc
Pipeline #9177 failed with stages
in 5 minutes and 46 seconds
......@@ -131,29 +131,30 @@ def migrate(migrator):
is_enabled=role["is_enabled"],
role_name=role.get("role_name", role["name"].lower())
).save()
if "telegraf" in role["name"].lower():
for n in Node.select().where(Node.environment == env):
Service(
environment=env.id,
service="telegraf",
pool=None,
node=n.id,
n_instances=1,
n_backup_instances=0,
loglevel="info"
).save()
Service(
environment=env.id,
service="monitoring",
pool=None,
node=n.id,
n_instances=1,
n_backup_instances=0,
loglevel="info"
).save()
config = yaml.load(env.service_config)
config[None]["telegraf"] = {
"telegraf_output_plugin": "influx"
}
env.service_config = yaml.dump(config)
env.save()
# Add telegraf role to all nodes
for n in Node.select().where(Node.environment == env):
Service(
environment=env.id,
service="telegraf",
pool=None,
node=n.id,
n_instances=1,
n_backup_instances=0,
loglevel="info"
).save()
Service(
environment=env.id,
service="monitoring",
pool=None,
node=n.id,
n_instances=1,
n_backup_instances=0,
loglevel="info"
).save()
# Adjust service config
config = yaml.load(env.service_config) or {None: {}}
config[None]["telegraf"] = {
"telegraf_output_plugin": "influx"
}
env.service_config = yaml.dump(config)
env.save()
......@@ -205,7 +205,7 @@ def migrate(migrator):
if srv.service in consul_template_depend_srv:
ct_promote_nodes.add(srv.node)
if srv.service == 'grafana':
if srv.service == 'grafana' and 'grafana' in conf:
conf['pg_password'] = conf.get('password', 'grafana')
if "password" in conf:
del conf['password']
......@@ -213,7 +213,7 @@ def migrate(migrator):
conf['max_clients'] = conf.get('pgbouncer_max_clients', 3000)
if "pgbouncer_max_clients" in conf:
del conf['pgbouncer_max_clients']
if srv.service == 'mongod':
if srv.service == 'mongod' and 'mongod' in conf:
conf['db'] = conf['mongod_db']
del conf['mongod_db']
conf['engine'] = conf['mongod_engine']
......@@ -226,18 +226,18 @@ def migrate(migrator):
del conf['mongod_user']
conf['logging_destination'] = conf['mongod_logging_destination']
del conf['mongod_logging_destination']
if srv.service == 'postgres':
if srv.service == 'postgres' and 'postgres' in conf:
conf['noc_db'] = conf['postgres_db']
del conf['postgres_db']
conf['noc_password'] = conf['postgres_password']
del conf['postgres_password']
conf['noc_user'] = conf['postgres_user']
del conf['postgres_user']
if srv.service == 'consul':
if srv.service == 'consul' and 'consul' in conf:
conf['master_token'] = conf.get('token', '')
if 'token' in conf:
del conf['token']
if srv.service == 'nginx':
if srv.service == 'nginx' and 'nginx' in conf:
conf['self_signed_cerificate'] = conf.get('certificate', True)
if 'certificate' in conf:
del conf['certificate']
......
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