diff --git a/changelog/64728.fixed.md b/changelog/64728.fixed.md new file mode 100644 index 00000000000..0d18efed6f3 --- /dev/null +++ b/changelog/64728.fixed.md @@ -0,0 +1 @@ +Cloud honors root_dir config settin when determining log file location diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 0af8c0c1f46..965da432222 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -2765,7 +2765,7 @@ def cloud_config( # prepend root_dir prepend_root_dirs = ["cachedir"] if "log_file" in opts and urllib.parse.urlparse(opts["log_file"]).scheme == "": - prepend_root_dirs.append(opts["log_file"]) + prepend_root_dirs.append("log_file") prepend_root_dir(opts, prepend_root_dirs) salt.features.setup_features(opts) diff --git a/tests/pytests/functional/test_config.py b/tests/pytests/functional/test_config.py index 76d25118f4a..e03a3b42d19 100644 --- a/tests/pytests/functional/test_config.py +++ b/tests/pytests/functional/test_config.py @@ -25,3 +25,16 @@ def test_minion_config_type_check(caplog): assert msg not in caplog.text finally: os.remove(path) + + +def test_cloud_config_relative_logfile(tmp_path): + root_path = tmp_path + config_path = tmp_path / "conf" + config_path.mkdir() + cloud_config = config_path / "cloud" + cloud_config.write_text("") + master_config = config_path / "master" + master_config = config_path / "master" + master_config.write_text(f"root_dir: {root_path}") + opts = salt.config.cloud_config(cloud_config) + assert opts["log_file"] == str(root_path / "var" / "log" / "salt" / "cloud")