From b99fffe34a3cb95d4ab468d2be5c502214c13d10 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Wed, 26 Jan 2022 19:59:05 +0000 Subject: [PATCH] Allow env var substitution in include paths --- plugins/inventory/float.py | 6 ++++-- scripts/pwgen.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/inventory/float.py b/plugins/inventory/float.py index e9fa22b6..81a01288 100644 --- a/plugins/inventory/float.py +++ b/plugins/inventory/float.py @@ -54,9 +54,11 @@ def _make_identifier(s): return s.replace('-', '_') -# Returns the absolute path to a file. If the given path is relative, -# it will be evaluated based on the given path_reference. +# Returns the absolute path to a file. Environment variables will be +# substituted. If the given path is relative, it will be evaluated +# based on the given path_reference. def _abspath(path, relative_to='/'): + path = os.path.expandvars(path) if path.startswith('/'): return path return os.path.abspath(os.path.join(os.path.dirname(relative_to), path)) diff --git a/scripts/pwgen.py b/scripts/pwgen.py index 07f999e9..9c67c3f4 100755 --- a/scripts/pwgen.py +++ b/scripts/pwgen.py @@ -19,9 +19,11 @@ EXIT_CHANGED = 1 EXIT_ERROR = 2 -# Returns the absolute path to a file. If the given path is relative, -# it will be evaluated based on the given path_reference. +# Returns the absolute path to a file. Environment variables will be +# substituted. If the given path is relative, it will be evaluated +# based on the given path_reference. def _abspath(path, relative_to='/'): + path = os.path.expandvars(path) if path.startswith('/'): return path return os.path.abspath(os.path.join(os.path.dirname(relative_to), path)) -- GitLab