diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-25 02:51:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-25 02:51:10 +0000 |
commit | eee9982be19a16d860b7e9dde05850e7f8c2276a (patch) | |
tree | 21d77352ca156d2d5671ffcdc88a65d4f7fb97b0 /lib/ansible/config/manager.py | |
parent | Releasing progress-linux version 2.16.5-1~progress7.99u1. (diff) | |
download | ansible-core-eee9982be19a16d860b7e9dde05850e7f8c2276a.tar.xz ansible-core-eee9982be19a16d860b7e9dde05850e7f8c2276a.zip |
Merging upstream version 2.16.6.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/config/manager.py')
-rw-r--r-- | lib/ansible/config/manager.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index 418528a..041e96e 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -305,6 +305,17 @@ class ConfigManager(object): # ensure we always have config def entry self._base_defs['CONFIG_FILE'] = {'default': None, 'type': 'path'} + def template_default(self, value, variables): + if isinstance(value, string_types) and (value.startswith('{{') and value.endswith('}}')) and variables is not None: + # template default values if possible + # NOTE: cannot use is_template due to circular dep + try: + t = NativeEnvironment().from_string(value) + value = t.render(variables) + except Exception: + pass # not templatable + return value + def _read_config_yaml_file(self, yml_file): # TODO: handle relative paths as relative to the directory containing the current playbook instead of CWD # Currently this is only used with absolute paths to the `ansible/config` directory @@ -548,17 +559,7 @@ class ConfigManager(object): to_native(_get_entry(plugin_type, plugin_name, config))) else: origin = 'default' - value = defs[config].get('default') - if isinstance(value, string_types) and (value.startswith('{{') and value.endswith('}}')) and variables is not None: - # template default values if possible - # NOTE: cannot use is_template due to circular dep - try: - t = NativeEnvironment().from_string(value) - value = t.render(variables) - except Exception: - pass # not templatable - - # ensure correct type, can raise exceptions on mismatched types + value = self.template_default(defs[config].get('default'), variables) try: value = ensure_type(value, defs[config].get('type'), origin=origin) except ValueError as e: |