hosts: add arch based on fedora and add detection for distro.
util: add pacman package manager and archlinux default package.
install: add distro detection and package selection
import logging
from ceph_deploy import exc
from ceph_deploy.util import versions
-from ceph_deploy.hosts import debian, centos, fedora, suse, remotes, rhel
+from ceph_deploy.hosts import debian, centos, fedora, suse, remotes, rhel, arch
from ceph_deploy.connection import get_connection
logger = logging.getLogger()
module.is_el = module.normalized_name in ['redhat', 'centos', 'fedora', 'scientific', 'oracle', 'virtuozzo']
module.is_rpm = module.normalized_name in ['redhat', 'centos',
'fedora', 'scientific', 'suse', 'oracle', 'virtuozzo']
- module.is_deb = not module.is_rpm
+ module.is_deb = module.normalized_name in ['debian', 'ubuntu']
+ module.is_pkgtarxz = module.normalized_name in ['arch']
module.release = release
module.codename = codename
module.conn = conn
'ubuntu': debian,
'centos': centos,
'scientific': centos,
- 'oracle' : centos,
+ 'oracle': centos,
'redhat': centos,
'fedora': fedora,
'suse': suse,
- 'virtuozzo' : centos
+ 'virtuozzo': centos,
+ 'arch': arch
}
if distro == 'redhat' and use_rhceph:
return 'ubuntu'
elif distro.startswith('virtuozzo'):
return 'virtuozzo'
+ elif distro.startswith('arch'):
+ return 'arch'
return distro
--- /dev/null
+from . import mon # noqa
+from ceph_deploy.hosts.centos.install import repo_install # noqa
+from .install import install, mirror_install # noqa
+from .uninstall import uninstall # noqa
+from ceph_deploy.util import pkg_managers
+
+# Allow to set some information about this distro
+#
+
+distro = None
+release = None
+codename = None
+
+
+def choose_init(module):
+ """
+ Select a init system
+
+ Returns the name of a init system (upstart, sysvinit ...).
+ """
+
+ return 'systemd'
+
+
+def get_packager(module):
+ return pkg_managers.Pacman(module)
--- /dev/null
+from ceph_deploy.hosts.centos.install import repo_install, mirror_install # noqa
+from ceph_deploy.hosts.common import map_components
+from ceph_deploy.util.system import enable_service, start_service
+
+
+NON_SPLIT_PACKAGES = [
+ 'ceph-osd',
+ 'ceph-radosgw',
+ 'ceph-mds',
+ 'ceph-mon',
+ 'ceph-mgr',
+ 'ceph-common',
+ 'ceph-test'
+]
+
+SYSTEMD_UNITS = [
+ 'ceph.target',
+ 'ceph-radosgw.target',
+ 'ceph-rbd-mirror.target',
+ 'ceph-fuse.target',
+ 'ceph-mds.target',
+ 'ceph-mon.target',
+ 'ceph-mgr.target',
+ 'ceph-osd.target',
+]
+SYSTEMD_UNITS_SKIP_START = [
+ 'ceph-mgr.target',
+ 'ceph-mon.target',
+]
+SYSTEMD_UNITS_SKIP_ENABLE = [
+]
+
+
+def install(distro, version_kind, version, adjust_repos, **kw):
+ packages = map_components(
+ NON_SPLIT_PACKAGES,
+ kw.pop('components', [])
+ )
+
+ distro.packager.install(
+ packages
+ )
+
+ # Start and enable services
+ for unit in SYSTEMD_UNITS:
+ if unit not in SYSTEMD_UNITS_SKIP_START:
+ start_service(distro.conn, unit)
+ if unit not in SYSTEMD_UNITS_SKIP_ENABLE:
+ enable_service(distro.conn, unit)
--- /dev/null
+from ceph_deploy.hosts.common import mon_add as add # noqa
+from ceph_deploy.hosts.common import mon_create as create # noqa
--- /dev/null
+import logging
+
+from ceph_deploy.util.system import disable_service, stop_service
+from ceph_deploy.lib import remoto
+
+
+SYSTEMD_UNITS = [
+ 'ceph-mds.target',
+ 'ceph-mon.target',
+ 'ceph-osd.target',
+ 'ceph-radosgw.target',
+ 'ceph-fuse.target',
+ 'ceph-mgr.target',
+ 'ceph-rbd-mirror.target',
+ 'ceph.target',
+]
+
+
+def uninstall(distro, purge=False):
+ packages = [
+ 'ceph',
+ ]
+
+ hostname = distro.conn.hostname
+ LOG = logging.getLogger(hostname)
+
+ # I need to stop and disable services prior package removal
+ LOG.info('stopping and disabling services on {}'.format(hostname))
+ for unit in SYSTEMD_UNITS:
+ stop_service(distro.conn, unit)
+ disable_service(distro.conn, unit)
+
+ # remoto.process.run(
+ # distro.conn,
+ # [
+ # 'systemctl',
+ # 'daemon-reload',
+ # ]
+ # )
+
+ LOG.info('uninstalling packages on {}'.format(hostname))
+ distro.packager.remove(packages)
+
+ remoto.process.run(
+ distro.conn,
+ [
+ 'systemctl',
+ 'reset-failed',
+ ]
+ )
if distro.is_rpm:
defaults = default_components.rpm
+ elif distro.is_pkgtarxz:
+ # archlinux doesn't have components!
+ flags = {
+ 'install_osd': 'ceph',
+ 'install_rgw': 'ceph',
+ 'install_mds': 'ceph',
+ 'install_mon': 'ceph',
+ 'install_mgr': 'ceph',
+ 'install_common': 'ceph',
+ 'install_tests': 'ceph',
+ }
+ defaults = default_components.pkgtarxz
else:
defaults = default_components.deb
# different naming convention for deb than rpm for radosgw
'ceph-mon',
]
-default_components = namedtuple('DefaultComponents', ['rpm', 'deb'])
+default_components = namedtuple('DefaultComponents', ['rpm', 'deb', 'pkgtarxz'])
# the difference here is because RPMs currently name the radosgw differently than DEBs.
# TODO: This needs to get unified once the packaging naming gets consistent
default_components.rpm = tuple(_base_components + ['ceph-radosgw'])
default_components.deb = tuple(_base_components + ['radosgw'])
+default_components.pkgtarxz = tuple(['ceph'])
gpg_key_base_url = "download.ceph.com/keys/"
def clean(self):
cmd = self.executable + ['refresh']
return self._run(cmd)
+
+
+class Pacman(PackageManager):
+ """
+ Pacman package management
+ """
+
+ executable = [
+ 'pacman',
+ '--noconfirm',
+ ]
+ name = 'pacman'
+
+ def install(self, packages, **kw):
+ if isinstance(packages, str):
+ packages = [packages]
+
+ extra_flags = kw.pop('extra_install_flags', None)
+ cmd = self.executable + [
+ '-Sy',
+ ]
+
+ if extra_flags:
+ if isinstance(extra_flags, str):
+ extra_flags = [extra_flags]
+ cmd.extend(extra_flags)
+ cmd.extend(packages)
+ return self._run(cmd)
+
+ def remove(self, packages, **kw):
+ if isinstance(packages, str):
+ packages = [packages]
+
+ extra_flags = kw.pop('extra_remove_flags', None)
+ cmd = self.executable + [
+ '-R'
+ ]
+ if extra_flags:
+ if isinstance(extra_flags, str):
+ extra_flags = [extra_flags]
+ cmd.extend(extra_flags)
+
+ cmd.extend(packages)
+ return self._run(cmd)
+
+ def clean(self):
+ cmd = self.executable + ['-Syy']
+ return self._run(cmd)
+
+ def add_repo_gpg_key(self, url):
+ cmd = ['pacman-key', '-a', url]
+ self._run(cmd)
'on',
]
)
+
+
+def disable_service(conn, service='ceph'):
+ """
+ Disable a service on a remote host depending on the type of init system.
+ Obviously, this should be done for RHEL/Fedora/CentOS systems.
+
+ This function does not do any kind of detection.
+ """
+ if is_systemd(conn):
+ # Without the check, an error is raised trying to disable an
+ # already disabled service
+ if is_systemd_service_enabled(conn, service):
+ remoto.process.run(
+ conn,
+ [
+ 'systemctl',
+ 'disable',
+ '{service}'.format(service=service),
+ ]
+ )
+
+
+def stop_service(conn, service='ceph'):
+ """
+ Stop a service on a remote host depending on the type of init system.
+ Obviously, this should be done for RHEL/Fedora/CentOS systems.
+
+ This function does not do any kind of detection.
+ """
+ if is_systemd(conn):
+ # Without the check, an error is raised trying to stop an
+ # already stopped service
+ if is_systemd_service_active(conn, service):
+ remoto.process.run(
+ conn,
+ [
+ 'systemctl',
+ 'stop',
+ '{service}'.format(service=service),
+ ]
+ )
+
+
+def start_service(conn, service='ceph'):
+ """
+ Stop a service on a remote host depending on the type of init system.
+ Obviously, this should be done for RHEL/Fedora/CentOS systems.
+
+ This function does not do any kind of detection.
+ """
+ if is_systemd(conn):
+ remoto.process.run(
+ conn,
+ [
+ 'systemctl',
+ 'start',
+ '{service}'.format(service=service),
+ ]
+ )
+
+
+def is_systemd_service_active(conn, service='ceph'):
+ """
+ Detects if a systemd service is active or not.
+ """
+ _, _, returncode = remoto.process.check(
+ conn,
+ [
+ 'systemctl',
+ 'is-active',
+ '--quiet',
+ '{service}'.format(service=service),
+ ]
+ )
+ return returncode == 0
+
+
+def is_systemd_service_enabled(conn, service='ceph'):
+ """
+ Detects if a systemd service is enabled or not.
+ """
+ _, _, returncode = remoto.process.check(
+ conn,
+ [
+ 'systemctl',
+ 'is-enabled',
+ '--quiet',
+ '{service}'.format(service=service),
+ ]
+ )
+ return returncode == 0