]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
debian/ubuntu: add systemd support 353/head
authorSage Weil <sage@redhat.com>
Thu, 10 Sep 2015 23:10:54 +0000 (19:10 -0400)
committerSage Weil <sage@redhat.com>
Thu, 10 Sep 2015 23:10:54 +0000 (19:10 -0400)
Prefer systemd over upstart if present (for newer ubuntu)

Signed-off-by: Sage Weil <sage@redhat.com>
ceph_deploy/hosts/debian/__init__.py
ceph_deploy/hosts/debian/mon/create.py

index 2c087dd66a44b327e1328fa87b2b8854aa64e698..b2ece01b2443d056b8048e3c45056d5a8d2a2703 100644 (file)
@@ -16,8 +16,11 @@ def choose_init(module):
 
     Returns the name of a init system (upstart, sysvinit ...).
     """
+    # fixme: newer ubuntu runs systemd
     if distro.lower() == 'ubuntu':
         return 'upstart'
+    if module.conn.remote_module.path_exists("/lib/systemd/system/ceph.target"):
+        return 'systemd'
     return 'sysvinit'
 
 
index 93d4393d4f6f17d402201e23dc0ff68efba7aecb..2a4d41d2dcaf6021cd91820f32d997d2351b2d22 100644 (file)
@@ -1,42 +1,69 @@
 from ceph_deploy.hosts import common
+from ceph_deploy.util import system
 from ceph_deploy.lib import remoto
 
 
 def create(distro, args, monitor_keyring):
-    logger = distro.conn.logger
     hostname = distro.conn.remote_module.shortname()
     common.mon_create(distro, args, monitor_keyring, hostname)
-    service = distro.conn.remote_module.which_service()
 
-    if not service:
-        logger.warning('could not find `service` executable')
-
-    if distro.init == 'upstart':  # Ubuntu uses upstart
+    if distro.init == 'sysvinit':
+        service = distro.conn.remote_module.which_service()
         remoto.process.run(
             distro.conn,
             [
-                'initctl',
-                'emit',
-                'ceph-mon',
-                'cluster={cluster}'.format(cluster=args.cluster),
-                'id={hostname}'.format(hostname=hostname),
+                service,
+                'ceph',
+                '-c',
+                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
+                'start',
+                'mon.{hostname}'.format(hostname=hostname)
             ],
             timeout=7,
         )
 
-    elif distro.init == 'sysvinit':  # Debian uses sysvinit
+        system.enable_service(distro.conn)
+    elif distro.init == 'upstart':
+        remoto.process.run(
+             distro.conn,
+             [
+                 'initctl',
+                 'emit',
+                 'ceph-mon',
+                 'cluster={cluster}'.format(cluster=args.cluster),
+                 'id={hostname}'.format(hostname=hostname),
+             ],
+             timeout=7,
+         )
 
+    elif distro.init == 'systemd':
+       # enable ceph target for this host (in case it isn't already enabled)
         remoto.process.run(
             distro.conn,
             [
-                service,
-                'ceph',
-                '-c',
-                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
+                'systemctl',
+                'enable',
+                'ceph.target'
+            ],
+            timeout=7,
+        )
+
+        # enable and start this mon instance
+        remoto.process.run(
+            distro.conn,
+            [
+                'systemctl',
+                'enable',
+                'ceph-mon@{hostname}'.format(hostname=hostname),
+            ],
+            timeout=7,
+        )
+        remoto.process.run(
+            distro.conn,
+            [
+                'systemctl',
                 'start',
-                'mon.{hostname}'.format(hostname=hostname)
+                'ceph-mon@{hostname}'.format(hostname=hostname),
             ],
             timeout=7,
         )
-    else:
-        raise RuntimeError('create cannot use init %s' % distro.init)