summaryrefslogtreecommitdiffstats
path: root/src/cephadm
diff options
context:
space:
mode:
Diffstat (limited to 'src/cephadm')
-rwxr-xr-xsrc/cephadm/cephadm.py20
-rw-r--r--src/cephadm/tests/test_cephadm.py3
2 files changed, 18 insertions, 5 deletions
diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py
index 5deaec55949..75ac3045c1e 100755
--- a/src/cephadm/cephadm.py
+++ b/src/cephadm/cephadm.py
@@ -2421,11 +2421,23 @@ def prepare_dashboard(
pathify(ctx.dashboard_crt.name): '/tmp/dashboard.crt:z',
pathify(ctx.dashboard_key.name): '/tmp/dashboard.key:z'
}
- cli(['dashboard', 'set-ssl-certificate', '-i', '/tmp/dashboard.crt'], extra_mounts=mounts)
- cli(['dashboard', 'set-ssl-certificate-key', '-i', '/tmp/dashboard.key'], extra_mounts=mounts)
else:
- logger.info('Generating a dashboard self-signed certificate...')
- cli(['dashboard', 'create-self-signed-cert'])
+ logger.info('Using certmgr to generate dashboard self-signed certificate...')
+ cert_key = json_loads_retry(lambda: cli(['orch', 'certmgr', 'generate-certificates', 'dashboard'],
+ verbosity=CallVerbosity.QUIET_UNLESS_ERROR))
+ mounts = {}
+ if cert_key:
+ cert_file = write_tmp(cert_key['cert'], uid, gid)
+ key_file = write_tmp(cert_key['key'], uid, gid)
+ mounts = {
+ cert_file.name: '/tmp/dashboard.crt:z',
+ key_file.name: '/tmp/dashboard.key:z'
+ }
+ else:
+ logger.error('Cannot generate certificates for Ceph dashboard.')
+
+ cli(['dashboard', 'set-ssl-certificate', '-i', '/tmp/dashboard.crt'], extra_mounts=mounts)
+ cli(['dashboard', 'set-ssl-certificate-key', '-i', '/tmp/dashboard.key'], extra_mounts=mounts)
logger.info('Creating initial admin user...')
password = ctx.initial_dashboard_password or generate_password()
diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py
index 6a5f4c9f00c..9e0345fe758 100644
--- a/src/cephadm/tests/test_cephadm.py
+++ b/src/cephadm/tests/test_cephadm.py
@@ -282,7 +282,8 @@ class TestCephAdm(object):
@mock.patch('cephadmlib.firewalld.Firewalld', mock_bad_firewalld)
@mock.patch('cephadm.Firewalld', mock_bad_firewalld)
@mock.patch('cephadm.logger')
- def test_skip_firewalld(self, _logger, cephadm_fs):
+ @mock.patch('cephadm.json_loads_retry', return_value=None)
+ def test_skip_firewalld(self, _logger, _jlr, cephadm_fs):
"""
test --skip-firewalld actually skips changing firewall
"""