From: Matthew Oliver Date: Tue, 21 Apr 2020 03:38:46 +0000 (+1000) Subject: cephadm: Make ceph-iscsi SSL aware X-Git-Tag: v16.1.0~2423^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4c942d05949f0cb79963258b6f75093bb5d1d4d9;p=ceph.git cephadm: Make ceph-iscsi SSL aware Ceph-iscsi's `rbd-target-api.py` supports listening over SSL if you provide an SSL cert and key. Originally the script is opinionated and requires these files to be named `/etc/ceph/iscsi-gateway.{crt,key}`. When dealing with containers, having to place files inside a container to enable SSL isn't very clean. To make things easier, like RGW, you can now place the SSL cert and key data in the mon config-key store. This will mean there are 2 ways to enable SSL in ceph-iscsi via orch/cephadm. 1. Push the SSL key and cert into the mon config-key under the keys, and then make sure api_secure is enabled (requires json): iscsi/{clientname}/iscsi-gateway.crt iscsi/{clientname}/iscsi-gateway.key 2. Provide the SSL key and cert in the json you pass the orchestrator and it'll push them up for you. Also lockdown the caps so the container can only access iscsi ssl key/certs. Signed-off-by: Matthew Oliver --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 89af9d14b04..8265c368f7d 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2868,10 +2868,34 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): ret, keyring, err = self.mon_command({ 'prefix': 'auth get-or-create', 'entity': utils.name_to_config_section('iscsi') + '.' + igw_id, - 'caps': ['mon', 'allow rw', + 'caps': ['mon', 'profile rbd, ' + 'allow command "osd blacklist", ' + 'allow command "config-key get" with "key" prefix "iscsi/"', 'osd', f'allow rwx pool={spec.pool}'], }) + if spec.ssl_cert: + if isinstance(spec.ssl_cert, list): + cert_data = '\n'.join(spec.ssl_cert) + else: + cert_data = spec.ssl_cert + ret, out, err = self.mon_command({ + 'prefix': 'config-key set', + 'key': f'iscsi/{utils.name_to_config_section("iscsi")}.{igw_id}/iscsi-gateway.crt', + 'val': cert_data, + }) + + if spec.ssl_key: + if isinstance(spec.ssl_key, list): + key_data = '\n'.join(spec.ssl_key) + else: + key_data = spec.ssl_key + ret, out, err = self.mon_command({ + 'prefix': 'config-key set', + 'key': f'iscsi/{utils.name_to_config_section("iscsi")}.{igw_id}/iscsi-gateway.key', + 'val': key_data, + }) + api_secure = 'false' if spec.api_secure is None else spec.api_secure igw_conf = f""" # generated by cephadm diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index 5bcf7d91a9a..6448fdac17d 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -599,6 +599,9 @@ class IscsiServiceSpec(ServiceSpec): self.ssl_cert = ssl_cert self.ssl_key = ssl_key + if not self.api_secure and self.ssl_cert and self.ssl_key: + self.api_secure = True + def validate_add(self): servicespec_validate_add(self)