"""
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
: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,
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)
return module
-def _get_distro(distro, fallback=None):
+def _get_distro(distro, fallback=None, use_rhceph=False):
if not distro:
return
'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):
--- /dev/null
+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'
--- /dev/null
+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'])
--- /dev/null
+from ceph_deploy.hosts.common import mon_add as add # noqa
+from create import create # noqa
--- /dev/null
+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)
--- /dev/null
+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
+ )
--- /dev/null
+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)
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,
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)
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)