From c7d84f93b11915b2668af225eedd33781bb9a07b Mon Sep 17 00:00:00 2001 From: Adam King Date: Wed, 10 Aug 2022 15:58:44 -0400 Subject: [PATCH] mgr/cephadm: set dashboard grafana-api-password when user provides one If a user provides this in the spec, cephadm will set up the inital admin user with the given password, but the conig setting accessed with "ceph dashboard get-grafana-api-password" is never updated. Cephadm can handle updating it since it's the one setting the password. Fixes: https://tracker.ceph.com/issues/57095 Signed-off-by: Adam King --- src/pybind/mgr/cephadm/services/ingress.py | 6 ++++-- src/pybind/mgr/cephadm/services/monitoring.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/cephadm/services/ingress.py b/src/pybind/mgr/cephadm/services/ingress.py index 02fd8141d5b52..a6429c43743ae 100644 --- a/src/pybind/mgr/cephadm/services/ingress.py +++ b/src/pybind/mgr/cephadm/services/ingress.py @@ -78,7 +78,8 @@ class IngressService(CephService): password = self.mgr.get_store(pw_key) if password is None: if not spec.monitor_password: - password = ''.join(random.choice(string.ascii_lowercase) for _ in range(self.MAX_KEEPALIVED_PASS_LEN)) + password = ''.join(random.choice(string.ascii_lowercase) + for _ in range(self.MAX_KEEPALIVED_PASS_LEN)) self.mgr.set_store(pw_key, password) else: if spec.monitor_password: @@ -177,7 +178,8 @@ class IngressService(CephService): password = self.mgr.get_store(pw_key) if password is None: if not spec.keepalived_password: - password = ''.join(random.choice(string.ascii_lowercase) for _ in range(self.MAX_KEEPALIVED_PASS_LEN)) + password = ''.join(random.choice(string.ascii_lowercase) + for _ in range(self.MAX_KEEPALIVED_PASS_LEN)) self.mgr.set_store(pw_key, password) else: if spec.keepalived_password: diff --git a/src/pybind/mgr/cephadm/services/monitoring.py b/src/pybind/mgr/cephadm/services/monitoring.py index d07c67bd5b979..03e8f3addb640 100644 --- a/src/pybind/mgr/cephadm/services/monitoring.py +++ b/src/pybind/mgr/cephadm/services/monitoring.py @@ -79,6 +79,10 @@ class GrafanaService(CephadmService): 'http_addr': daemon_spec.ip if daemon_spec.ip else '' }) + if 'dashboard' in self.mgr.get('mgr_map')['modules'] and spec.initial_admin_password: + self.mgr.check_mon_command( + {'prefix': 'dashboard set-grafana-api-password'}, inbuf=spec.initial_admin_password) + config_file = { 'files': { "grafana.ini": grafana_ini, -- 2.39.5