]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
Detect and support both systemd and sysvinit on Fedora, RHEL and CentOS 344/head
authorMilan Broz <mbroz@redhat.com>
Tue, 11 Aug 2015 07:05:04 +0000 (09:05 +0200)
committerMilan Broz <mbroz@redhat.com>
Tue, 11 Aug 2015 07:12:51 +0000 (09:12 +0200)
To properly install systemd-enabled and old (sysvinit) Ceph packages
we need to properly detect when systemd target is used.

This cannot be done just by checking distro version, it depends
on Ceph package content (sysvinit can be used on systemd distro as well).

Let's check ceph.target existence and enable systemd only in this case.

Signed-off-by: Milan Broz <mbroz@redhat.com>
ceph_deploy/hosts/centos/__init__.py
ceph_deploy/hosts/centos/mon/create.py
ceph_deploy/hosts/fedora/__init__.py
ceph_deploy/hosts/fedora/mon/create.py
ceph_deploy/hosts/rhel/__init__.py
ceph_deploy/hosts/rhel/mon/create.py

index 0b8cb6bb900fa01ea7e03a5003fa9546b1779294..38a51b73215ffe083619d9a6ecb4c1af5a31848c 100644 (file)
@@ -17,8 +17,14 @@ def choose_init(module):
 
     Returns the name of a init system (upstart, sysvinit ...).
     """
-    return 'sysvinit'
 
+    if module.normalized_release.int_major < 7:
+        return 'sysvinit'
+
+    if not module.conn.remote_module.path_exists("/usr/lib/systemd/system/ceph.target"):
+        return 'sysvinit'
+
+    return 'systemd'
 
 def get_packager(module):
     return pkg_managers.Yum(module)
index bfc623187f8365529877d8be299ed638ad75517b..7579aa797695a57024f8a5394f44c5e886f8628a 100644 (file)
@@ -6,19 +6,51 @@ from ceph_deploy.lib import remoto
 def create(distro, args, monitor_keyring):
     hostname = distro.conn.remote_module.shortname()
     common.mon_create(distro, args, monitor_keyring, hostname)
-    service = distro.conn.remote_module.which_service()
 
-    remoto.process.run(
-        distro.conn,
-        [
-            service,
-            'ceph',
-            '-c',
-            '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
-            'start',
-            'mon.{hostname}'.format(hostname=hostname)
-        ],
-        timeout=7,
-    )
+    if distro.init == 'sysvinit':
+        service = distro.conn.remote_module.which_service()
+        remoto.process.run(
+            distro.conn,
+            [
+                service,
+                'ceph',
+                '-c',
+                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
+                'start',
+                'mon.{hostname}'.format(hostname=hostname)
+            ],
+            timeout=7,
+        )
 
-    system.enable_service(distro.conn)
+        system.enable_service(distro.conn)
+    elif distro.init == 'systemd':
+       # enable ceph target for this host (in case it isn't already enabled)
+        remoto.process.run(
+            distro.conn,
+            [
+                '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',
+                'ceph-mon@{hostname}'.format(hostname=hostname),
+            ],
+            timeout=7,
+        )
index 9de01bbd9723095a5099b544592de3e3c31ceec4..8f56c134434652b116a96a80b5e367f8035f9958 100644 (file)
@@ -17,11 +17,12 @@ def choose_init(module):
 
     Returns the name of a init system (upstart, sysvinit ...).
     """
-    if module.normalized_release.int_major >= 22:
-        return 'systemd'
-    else:
+
+    if not module.conn.remote_module.path_exists("/usr/lib/systemd/system/ceph.target"):
         return 'sysvinit'
 
+    return 'systemd'
+
 def get_packager(module):
     if module.normalized_release.int_major >= 22:
         return pkg_managers.DNF(module)
index 139e00e1c590cd2e3562b1ffcbf84fd86364e9d2..7579aa797695a57024f8a5394f44c5e886f8628a 100644 (file)
@@ -1,4 +1,5 @@
 from ceph_deploy.hosts import common
+from ceph_deploy.util import system
 from ceph_deploy.lib import remoto
 
 
@@ -6,33 +7,50 @@ def create(distro, args, monitor_keyring):
     hostname = distro.conn.remote_module.shortname()
     common.mon_create(distro, args, monitor_keyring, hostname)
 
-    # enable ceph target for this host (in case it isn't already enabled)
-    remoto.process.run(
-        distro.conn,
-        [
-            'systemctl',
-            'enable',
-            'ceph.target'
-        ],
-        timeout=7,
-    )
+    if distro.init == 'sysvinit':
+        service = distro.conn.remote_module.which_service()
+        remoto.process.run(
+            distro.conn,
+            [
+                service,
+                'ceph',
+                '-c',
+                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
+                'start',
+                'mon.{hostname}'.format(hostname=hostname)
+            ],
+            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',
-            'ceph-mon@{hostname}'.format(hostname=hostname),
-        ],
-        timeout=7,
-    )
+        system.enable_service(distro.conn)
+    elif distro.init == 'systemd':
+       # enable ceph target for this host (in case it isn't already enabled)
+        remoto.process.run(
+            distro.conn,
+            [
+                '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',
+                'ceph-mon@{hostname}'.format(hostname=hostname),
+            ],
+            timeout=7,
+        )
index f32c46ad3c424c345a19e42b86ecb89a8bd41004..e323da13dd9eeb7251edba5f7a5192f6c176141f 100644 (file)
@@ -16,8 +16,14 @@ def choose_init(module):
 
     Returns the name of a init system (upstart, sysvinit ...).
     """
-    return 'sysvinit'
 
+    if module.normalized_release.int_major < 7:
+        return 'sysvinit'
+
+    if not module.conn.remote_module.path_exists("/usr/lib/systemd/system/ceph.target"):
+        return 'sysvinit'
+
+    return 'systemd'
 
 def get_packager(module):
     return pkg_managers.Yum(module)
index bfc623187f8365529877d8be299ed638ad75517b..7579aa797695a57024f8a5394f44c5e886f8628a 100644 (file)
@@ -6,19 +6,51 @@ from ceph_deploy.lib import remoto
 def create(distro, args, monitor_keyring):
     hostname = distro.conn.remote_module.shortname()
     common.mon_create(distro, args, monitor_keyring, hostname)
-    service = distro.conn.remote_module.which_service()
 
-    remoto.process.run(
-        distro.conn,
-        [
-            service,
-            'ceph',
-            '-c',
-            '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
-            'start',
-            'mon.{hostname}'.format(hostname=hostname)
-        ],
-        timeout=7,
-    )
+    if distro.init == 'sysvinit':
+        service = distro.conn.remote_module.which_service()
+        remoto.process.run(
+            distro.conn,
+            [
+                service,
+                'ceph',
+                '-c',
+                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
+                'start',
+                'mon.{hostname}'.format(hostname=hostname)
+            ],
+            timeout=7,
+        )
 
-    system.enable_service(distro.conn)
+        system.enable_service(distro.conn)
+    elif distro.init == 'systemd':
+       # enable ceph target for this host (in case it isn't already enabled)
+        remoto.process.run(
+            distro.conn,
+            [
+                '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',
+                'ceph-mon@{hostname}'.format(hostname=hostname),
+            ],
+            timeout=7,
+        )