From 90308de33a1217f55aba1911bf153d9ee871e3d8 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 6 Mar 2020 15:20:24 -0600 Subject: [PATCH] cephadm: shell: default to config and keyring in /etc/ceph, if present This just makes things painless for humans: they can usually run 'cephadm shell' and have a working environment. Signed-off-by: Sage Weil --- src/cephadm/cephadm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 4b51eb4c7ff..18104fcc074 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -12,6 +12,8 @@ CONTAINER_PREFERENCE = ['podman', 'docker'] # prefer podman to docker CUSTOM_PS1=r'[ceph: \u@\h \W]\$ ' DEFAULT_TIMEOUT=None # in seconds DEFAULT_RETRY=10 +SHELL_DEFAULT_CONF='/etc/ceph/ceph.conf' +SHELL_DEFAULT_KEYRING='/etc/ceph/ceph.client.admin.keyring' """ You can invoke cephadm in two ways: @@ -2198,6 +2200,14 @@ def command_shell(): if daemon_id and not args.fsid: raise Error('must pass --fsid to specify cluster') + # use /etc/ceph files by default, if present. we do this instead of + # making these defaults in the arg parser because we don't want an error + # if they don't exist. + if not args.config and os.path.exists(SHELL_DEFAULT_CONF): + args.config = SHELL_DEFAULT_CONF + if not args.keyring and os.path.exists(SHELL_DEFAULT_KEYRING): + args.keyring = SHELL_DEFAULT_KEYRING + container_args = [] # type: List[str] mounts = get_container_mounts(args.fsid, daemon_type, daemon_id, no_config=True if args.config else False) -- 2.39.5