]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
Add support for RHEL host module
authorTravis Rhoden <trhoden@redhat.com>
Mon, 16 Feb 2015 14:42:48 +0000 (09:42 -0500)
committerAlfredo Deza <alfredo.deza@inktank.com>
Thu, 19 Feb 2015 18:40:22 +0000 (13:40 -0500)
When "use_rhceph" is set in cephdeploy.conf, no longer use
the centos host module as a stand-in for RHEL, use a new
rhel host module that is designed to be used for the Red Hat
distributed Red Hat Ceph product.

Right now this means not using Yum priorities, and installing
two new packages of ceph-mon and ceph-osd.  Eventually ceph-deploy
needs to be smarter of only installing ceph-mon or ceph-osd when a
host needs it, but for now just install both.

Signed-off-by: Travis Rhoden <trhoden@redhat.com>
ceph_deploy/hosts/__init__.py
ceph_deploy/hosts/rhel/__init__.py [new file with mode: 0644]
ceph_deploy/hosts/rhel/install.py [new file with mode: 0644]
ceph_deploy/hosts/rhel/mon/__init__.py [new file with mode: 0644]
ceph_deploy/hosts/rhel/mon/create.py [new file with mode: 0644]
ceph_deploy/hosts/rhel/pkg.py [new file with mode: 0644]
ceph_deploy/hosts/rhel/uninstall.py [new file with mode: 0644]
ceph_deploy/install.py

index 60d6c027b5e7c3bdd9d40a51577157e25768c0f2..a662304d76bdad9d2fddc04f939f935686d29e8d 100644 (file)
@@ -6,17 +6,21 @@ on the type of distribution/version we are dealing with.
 """
 import logging
 from ceph_deploy import exc
-from ceph_deploy.hosts import debian, centos, fedora, suse, remotes
+from ceph_deploy.hosts import debian, centos, fedora, suse, remotes, rhel
 from ceph_deploy.connection import get_connection
 
 logger = logging.getLogger()
 
 
-def get(hostname, username=None, fallback=None, detect_sudo=True):
+def get(hostname,
+        username=None,
+        fallback=None,
+        detect_sudo=True,
+        use_rhceph=False):
     """
     Retrieve the module that matches the distribution of a ``hostname``. This
     function will connect to that host and retrieve the distribution
-    informaiton, then return the appropriate module and slap a few attributes
+    information, then return the appropriate module and slap a few attributes
     to that module defining the information it found from the hostname.
 
     For example, if host ``node1.example.com`` is an Ubuntu server, the
@@ -28,6 +32,9 @@ def get(hostname, username=None, fallback=None, detect_sudo=True):
 
     :param hostname: A hostname that is reachable/resolvable over the network
     :param fallback: Optional fallback to use if no supported distro is found
+    :param use_rhceph: Whether or not to install RH Ceph on a RHEL machine or
+                       the community distro.  Changes what host module is
+                       returned for RHEL.
     """
     conn = get_connection(
         hostname,
@@ -48,7 +55,7 @@ def get(hostname, username=None, fallback=None, detect_sudo=True):
             release=release)
 
     machine_type = conn.remote_module.machine_type()
-    module = _get_distro(distro_name)
+    module = _get_distro(distro_name, use_rhceph=use_rhceph)
     module.name = distro_name
     module.normalized_name = _normalized_distro_name(distro_name)
     module.normalized_release = _normalized_release(release)
@@ -62,7 +69,7 @@ def get(hostname, username=None, fallback=None, detect_sudo=True):
     return module
 
 
-def _get_distro(distro, fallback=None):
+def _get_distro(distro, fallback=None, use_rhceph=False):
     if not distro:
         return
 
@@ -77,7 +84,10 @@ def _get_distro(distro, fallback=None):
         'suse': suse,
         }
 
-    return distributions.get(distro) or _get_distro(fallback)
+    if distro == 'redhat' and use_rhceph:
+        return rhel
+    else:
+        return distributions.get(distro) or _get_distro(fallback)
 
 
 def _normalized_distro_name(distro):
diff --git a/ceph_deploy/hosts/rhel/__init__.py b/ceph_deploy/hosts/rhel/__init__.py
new file mode 100644 (file)
index 0000000..13f7b22
--- /dev/null
@@ -0,0 +1,19 @@
+import mon  # noqa
+import pkg  # noqa
+from install import install, mirror_install, repo_install  # noqa
+from uninstall import uninstall  # noqa
+
+# Allow to set some information about this distro
+#
+
+distro = None
+release = None
+codename = None
+
+def choose_init():
+    """
+    Select a init system
+
+    Returns the name of a init system (upstart, sysvinit ...).
+    """
+    return 'sysvinit'
diff --git a/ceph_deploy/hosts/rhel/install.py b/ceph_deploy/hosts/rhel/install.py
new file mode 100644 (file)
index 0000000..c65b10c
--- /dev/null
@@ -0,0 +1,78 @@
+from ceph_deploy.util import pkg_managers, templates
+from ceph_deploy.lib import remoto
+
+
+def install(distro, version_kind, version, adjust_repos):
+    pkg_managers.yum_clean(distro.conn)
+    pkg_managers.yum(distro.conn, ['ceph', 'ceph-mon', 'ceph-osd'])
+
+
+def mirror_install(distro, repo_url, gpg_url, adjust_repos, extra_installs=True):
+    repo_url = repo_url.strip('/')  # Remove trailing slashes
+    gpg_url_path = gpg_url.split('file://')[-1]  # Remove file if present
+
+    pkg_managers.yum_clean(distro.conn)
+
+    if adjust_repos:
+        remoto.process.run(
+            distro.conn,
+            [
+                'rpm',
+                '--import',
+                gpg_url_path,
+            ]
+        )
+
+        ceph_repo_content = templates.ceph_repo.format(
+            repo_url=repo_url,
+            gpg_url=gpg_url
+        )
+
+        distro.conn.remote_module.write_yum_repo(ceph_repo_content)
+
+    if extra_installs:
+        pkg_managers.yum(distro.conn, ['ceph', 'ceph-mon', 'ceph-osd'])
+
+
+def repo_install(distro, reponame, baseurl, gpgkey, **kw):
+    # Get some defaults
+    name = kw.pop('name', '%s repo' % reponame)
+    enabled = kw.pop('enabled', 1)
+    gpgcheck = kw.pop('gpgcheck', 1)
+    install_ceph = kw.pop('install_ceph', False)
+    proxy = kw.pop('proxy', '') # will get ignored if empty
+    _type = 'repo-md'
+    baseurl = baseurl.strip('/')  # Remove trailing slashes
+
+    pkg_managers.yum_clean(distro.conn)
+
+    if gpgkey:
+        remoto.process.run(
+            distro.conn,
+            [
+                'rpm',
+                '--import',
+                gpgkey,
+            ]
+        )
+
+    repo_content = templates.custom_repo(
+        reponame=reponame,
+        name=name,
+        baseurl=baseurl,
+        enabled=enabled,
+        gpgcheck=gpgcheck,
+        _type=_type,
+        gpgkey=gpgkey,
+        proxy=proxy,
+        **kw
+    )
+
+    distro.conn.remote_module.write_yum_repo(
+        repo_content,
+        "%s.repo" % reponame
+    )
+
+    # Some custom repos do not need to install ceph
+    if install_ceph:
+        pkg_managers.yum(distro.conn, ['ceph', 'ceph-mon', 'ceph-osd'])
diff --git a/ceph_deploy/hosts/rhel/mon/__init__.py b/ceph_deploy/hosts/rhel/mon/__init__.py
new file mode 100644 (file)
index 0000000..936d5d8
--- /dev/null
@@ -0,0 +1,2 @@
+from ceph_deploy.hosts.common import mon_add as add  # noqa
+from create import create  # noqa
diff --git a/ceph_deploy/hosts/rhel/mon/create.py b/ceph_deploy/hosts/rhel/mon/create.py
new file mode 100644 (file)
index 0000000..bfc6231
--- /dev/null
@@ -0,0 +1,24 @@
+from ceph_deploy.hosts import common
+from ceph_deploy.util import system
+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,
+    )
+
+    system.enable_service(distro.conn)
diff --git a/ceph_deploy/hosts/rhel/pkg.py b/ceph_deploy/hosts/rhel/pkg.py
new file mode 100644 (file)
index 0000000..eb02bfd
--- /dev/null
@@ -0,0 +1,15 @@
+from ceph_deploy.util import pkg_managers
+
+
+def install(distro, packages):
+    return pkg_managers.yum(
+        distro.conn,
+        packages
+    )
+
+
+def remove(distro, packages):
+    return pkg_managers.yum_remove(
+        distro.conn,
+        packages
+    )
diff --git a/ceph_deploy/hosts/rhel/uninstall.py b/ceph_deploy/hosts/rhel/uninstall.py
new file mode 100644 (file)
index 0000000..432d441
--- /dev/null
@@ -0,0 +1,17 @@
+from ceph_deploy.util import pkg_managers
+
+
+def uninstall(conn, purge=False):
+    packages = [
+        'ceph',
+        'ceph-common',
+        'ceph-mon',
+        'ceph-osd'
+        ]
+
+    pkg_managers.yum_remove(
+        conn,
+        packages,
+    )
+
+    pkg_managers.yum_clean(conn)
index 538c277f6ce5f60099de64aa44c7046f1480f761..84bc865280bcfbdbc43ce1af10a460c68480a97b 100644 (file)
@@ -37,7 +37,10 @@ def install(args):
 
     for hostname in args.host:
         LOG.debug('Detecting platform for host %s ...', hostname)
-        distro = hosts.get(hostname, username=args.username)
+        distro = hosts.get(
+            hostname,
+            username=args.username,
+            use_rhceph=bool(getattr(args, 'use_rhceph', False)))
         LOG.info(
             'Distro info: %s %s %s',
             distro.name,
@@ -214,7 +217,10 @@ def uninstall(args):
     for hostname in args.host:
         LOG.debug('Detecting platform for host %s ...', hostname)
 
-        distro = hosts.get(hostname, username=args.username)
+        distro = hosts.get(
+            hostname,
+            username=args.username,
+            use_rhceph=bool(getattr(args, 'use_rhceph', False)))
         LOG.info('Distro info: %s %s %s', distro.name, distro.release, distro.codename)
         rlogger = logging.getLogger(hostname)
         rlogger.info('uninstalling ceph on %s' % hostname)
@@ -235,7 +241,10 @@ def purge(args):
     for hostname in args.host:
         LOG.debug('Detecting platform for host %s ...', hostname)
 
-        distro = hosts.get(hostname, username=args.username)
+        distro = hosts.get(
+            hostname,
+            username=args.username,
+            use_rhceph=bool(getattr(args, 'use_rhceph', False)))
         LOG.info('Distro info: %s %s %s', distro.name, distro.release, distro.codename)
         rlogger = logging.getLogger(hostname)
         rlogger.info('purging host ... %s' % hostname)