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 <neoaggelos@gmail.com>
This commit is contained in:
Angelos Kolaitis committed 2023-07-17 20:34:29 +03:00
1 parent 1913413ddf
commit c021256e96
2 files changed
+9 -1

No files matched your search

@@ -44,6 +44,7 @@ python3 create-external-cluster-resources.py --rbd-data-pool-name <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
@@ -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()