From c021256e96bcd5bfc607d67f2b65651ccf84263e Mon Sep 17 00:00:00 2001 From: Angelos Kolaitis Date: Tue, 11 Jul 2023 16:04:42 +0300 Subject: [PATCH] external: support custom ceph keyring file When the ceph.conf is not in a well-known location, it is typical for a custom ceph.keyring to be required as well. Currently, the create-external-cluster-resources.py only tries to load the keyring from well-known paths, and fails. This commit adds a new optional argument `--keyring` to help in this situation. When specified, create-external-cluster-resources.py will attempt to use this as the keyring to authenticate with Ceph. Signed-off-by: Angelos Kolaitis --- Documentation/CRDs/Cluster/external-cluster.md | 1 + deploy/examples/create-external-cluster-resources.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/CRDs/Cluster/external-cluster.md b/Documentation/CRDs/Cluster/external-cluster.md index aadf5314d..46a14aa70 100644 --- a/Documentation/CRDs/Cluster/external-cluster.md +++ b/Documentation/CRDs/Cluster/external-cluster.md @@ -44,6 +44,7 @@ python3 create-external-cluster-resources.py --rbd-data-pool-name -- - `--monitoring-endpoint-port`: (optional) Ceph Manager prometheus exporter port - `--skip-monitoring-endpoint`: (optional) Skip prometheus exporter endpoints, even if they are available. Useful if the prometheus module is not enabled - `--ceph-conf`: (optional) Provide a Ceph conf file +- `--keyring`: (optional) Path to Ceph keyring file, to be used with `--ceph-conf` - `--cluster-name`: (optional) Ceph cluster name - `--output`: (optional) Output will be stored into the provided file - `--dry-run`: (optional) Prints the executed commands without running them diff --git a/deploy/examples/create-external-cluster-resources.py b/deploy/examples/create-external-cluster-resources.py index 8380c1596..760533377 100644 --- a/deploy/examples/create-external-cluster-resources.py +++ b/deploy/examples/create-external-cluster-resources.py @@ -308,6 +308,9 @@ class RadosJSON: common_group.add_argument( "--ceph-conf", "-c", help="Provide a ceph conf file.", type=str ) + common_group.add_argument( + "--keyring", "-k", help="Path to ceph keyring file.", type=str + ) common_group.add_argument( "--run-as-user", "-u", @@ -617,6 +620,7 @@ class RadosJSON: self.run_as_user = self._arg_parser.run_as_user self.output_file = self._arg_parser.output self.ceph_conf = self._arg_parser.ceph_conf + self.ceph_keyring = self._arg_parser.keyring self.MIN_USER_CAP_PERMISSIONS = { "mgr": "allow command config", "mon": "allow r, allow command quorum_status, allow command version", @@ -632,7 +636,10 @@ class RadosJSON: if not self._arg_parser.rgw_pool_prefix and not self._arg_parser.upgrade: self._arg_parser.rgw_pool_prefix = self.DEFAULT_RGW_POOL_PREFIX if self.ceph_conf: - self.cluster = rados.Rados(conffile=self.ceph_conf) + kwargs = {} + if self.ceph_keyring: + kwargs["conf"] = {"keyring": self.ceph_keyring} + self.cluster = rados.Rados(conffile=self.ceph_conf, **kwargs) else: self.cluster = rados.Rados() self.cluster.conf_read_file()