diff --git a/src/config.example.yaml b/src/config.example.yaml index d382e8e..771b2c8 100644 --- a/src/config.example.yaml +++ b/src/config.example.yaml @@ -35,6 +35,7 @@ rook: image: quay.io/ceph/ceph:v18.2.1 migration_modules: +- cephx_auth_config - migrate_osds - migrate_monitors - example diff --git a/src/rookify/modules/cephx_auth_config/__init__.py b/src/rookify/modules/cephx_auth_config/__init__.py new file mode 100644 index 0000000..6070741 --- /dev/null +++ b/src/rookify/modules/cephx_auth_config/__init__.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# type: ignore + +from .main import CephXAuthHandler + +MODULE_NAME = "cephx_auth_config" +HANDLER_CLASS = CephXAuthHandler +REQUIRES = [] +AFTER = [] +PREFLIGHT_REQUIRES = [] diff --git a/src/rookify/modules/cephx_auth_config/main.py b/src/rookify/modules/cephx_auth_config/main.py new file mode 100644 index 0000000..45248d6 --- /dev/null +++ b/src/rookify/modules/cephx_auth_config/main.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from ..module import ModuleHandler +from typing import Any + + +class CephXAuthHandler(ModuleHandler): + def run(self) -> Any: + self.logger.debug("Reconfiguring Ceph to expect cephx auth") + + self.ceph.conf_set("auth_cluster_required", "cephx") + self.ceph.conf_set("auth_service_required", "cephx") + self.ceph.conf_set("auth_client_required", "cephx") + + self.logger.info("Reconfigured Ceph to expect cephx auth") + return {"reconfigured": True} diff --git a/src/rookify/modules/module.py b/src/rookify/modules/module.py index bffacd5..8642717 100644 --- a/src/rookify/modules/module.py +++ b/src/rookify/modules/module.py @@ -32,6 +32,9 @@ def __init__(self, config: Dict[str, Any]): except rados.ObjectNotFound as err: raise ModuleException(f"Could not connect to ceph: {err}") + def __getattr__(self, name: str) -> Any: + return getattr(self.__ceph, name) + def mon_command( self, command: str, **kwargs: str ) -> Dict[str, Any] | List[Any]: @@ -166,7 +169,7 @@ def __init__(self, config: Dict[str, Any], data: Dict[str, Any], module_path: st self.__ssh: Optional[ModuleHandler.__SSH] = None self.__logger = get_logger() - self.__logger.debug("Executing {0}", self.__class__.__name__) + self.__logger.debug("Executing {0}".format(self.__class__.__name__)) @abc.abstractmethod def preflight(self) -> None: