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
This commit is contained in:
Corey Bryant 2017-08-08 20:06:30 +00:00
parent 21b51dedd9
commit 94e2db92e1
2 changed files with 29 additions and 0 deletions

View File

@ -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())

View File

@ -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)