From d77fb7f36e3e286d8a82302b581f66305e79d429 Mon Sep 17 00:00:00 2001 From: Paul Cuzner Date: Mon, 14 Dec 2020 11:15:38 +1300 Subject: [PATCH] cephadm: create default output dir during bootstrap If the output dir doesn't exist the old behaviour was to abort bootstrap. Since we're running with UID=0, this patch will create the missing dirs for the user to keep the bootstrap process going Signed-off-by: Paul Cuzner (cherry picked from commit 27b5eada81189ad01b31ff34bf0e362353cfbd92) --- src/cephadm/cephadm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 1dd67a71acea0..b1381126fb0b8 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2797,7 +2797,14 @@ def command_bootstrap(): '--allow-overwrite to overwrite' % f) dirname = os.path.dirname(f) if dirname and not os.path.exists(dirname): - raise Error('%s directory %s does not exist' % (f, dirname)) + fname = os.path.basename(f) + logger.info(f"Creating directory {dirname} for {fname}") + try: + # use makedirs to create intermediate missing dirs + os.makedirs(dirname, 0o700) + except PermissionError: + raise Error(f"Unable to create {dirname} due to permissions failure. Retry with root, or sudo or preallocate the directory.") + if not args.skip_prepare_host: command_prepare_host() -- 2.39.5