From 94e2db92e12209b3b87da472f783d39e652681d2 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Tue, 8 Aug 2017 20:06:30 +0000 Subject: [PATCH] Bootstrap ceph-mgr daemon As of the Luminous release, Ceph requires ceph-mgr daemons be run to have a fully functional cluster. [0] [0] http://docs.ceph.com/docs/master/mgr/administrator/ Change-Id: I59e4d20c0e3c2d3e4cff45aaa70adf5b2862f71b Closes-bug: #1709061 --- hooks/ceph_hooks.py | 8 ++++++++ lib/ceph/__init__.py | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index c6a52d4..fa6f343 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -296,6 +296,9 @@ def config_changed(): status_set('maintenance', 'Bootstrapping single Ceph MON') ceph.bootstrap_monitor_cluster(config('monitor-secret')) ceph.wait_for_bootstrap() + if cmp_pkgrevno('ceph', '12.0.0') >= 0: + status_set('maintenance', 'Bootstrapping single Ceph MGR') + ceph.bootstrap_manager() storage_changed() @@ -404,6 +407,9 @@ def mon_relation(): status_set('maintenance', 'Bootstrapping MON cluster') ceph.bootstrap_monitor_cluster(config('monitor-secret')) ceph.wait_for_bootstrap() + if cmp_pkgrevno('ceph', '12.0.0') >= 0: + status_set('maintenance', 'Bootstrapping Ceph MGR') + ceph.bootstrap_manager() for dev in get_devices(): ceph.osdize(dev, config('osd-format'), get_osd_journal(), reformat_osd(), config('ignore-device-errors'), @@ -570,6 +576,8 @@ def start(): service_restart('ceph-mon') else: service_restart('ceph-mon-all') + if cmp_pkgrevno('ceph', '12.0.0') >= 0: + service_restart('ceph-mgr@{}'.format(socket.gethostname())) if ceph.is_bootstrapped(): ceph.start_osds(get_devices()) diff --git a/lib/ceph/__init__.py b/lib/ceph/__init__.py index 7f8d3a4..6aaf4fa 100644 --- a/lib/ceph/__init__.py +++ b/lib/ceph/__init__.py @@ -1314,6 +1314,27 @@ def bootstrap_monitor_cluster(secret): os.unlink(keyring) +def bootstrap_manager(): + hostname = socket.gethostname() + path = '/var/lib/ceph/mgr/ceph-{}'.format(hostname) + keyring = os.path.join(path, 'keyring') + + if os.path.exists(keyring): + log('bootstrap_manager: mgr already initialized.') + else: + mkdir(path, owner=ceph_user(), group=ceph_user()) + subprocess.check_call(['ceph', 'auth', 'get-or-create', + 'mgr.{}'.format(hostname), 'mon', + 'allow profile mgr', 'osd', 'allow *', + 'mds', 'allow *', '--out-file', + keyring]) + chownr(path, ceph_user(), ceph_user()) + + unit = 'ceph-mgr@{}'.format(hostname) + subprocess.check_call(['systemctl', 'enable', unit]) + service_restart(unit) + + def update_monfs(): hostname = socket.gethostname() monfs = '/var/lib/ceph/mon/ceph-{}'.format(hostname)