diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2018-06-29 19:45:38 -0400 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2018-06-29 16:45:38 -0700 |
commit | de0e11c0d5480a03dc0ecb71028505f229722f78 (patch) | |
tree | aa545ea48c5122e040489a06dea6c806d169ebd3 /lib/ansible/vars/manager.py | |
parent | c3134ce6e2ac27e70feddb8c65a1aec6bfdbce52 (diff) | |
download | ansible-de0e11c0d5480a03dc0ecb71028505f229722f78.tar.gz |
avoid loading vars on unspecified basedir (cwd) (#42067)
* avoid loading vars on unspecified basedir (cwd)
Diffstat (limited to 'lib/ansible/vars/manager.py')
-rw-r--r-- | lib/ansible/vars/manager.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ansible/vars/manager.py b/lib/ansible/vars/manager.py index 6f104b518d..07669ec625 100644 --- a/lib/ansible/vars/manager.py +++ b/lib/ansible/vars/manager.py @@ -90,6 +90,7 @@ class VariableManager: self._hostvars = None self._omit_token = '__omit_place_holder__%s' % sha1(os.urandom(64)).hexdigest() self._options_vars = defaultdict(dict) + self.safe_basedir = False # bad cache plugin is not fatal error try: @@ -110,6 +111,7 @@ class VariableManager: omit_token=self._omit_token, options_vars=self._options_vars, inventory=self._inventory, + safe_basedir=self.safe_basedir, ) return data @@ -123,6 +125,7 @@ class VariableManager: self._omit_token = data.get('omit_token', '__omit_place_holder__%s' % sha1(os.urandom(64)).hexdigest()) self._inventory = data.get('inventory', None) self._options_vars = data.get('options_vars', dict()) + self.safe_basedir = data.get('safe_basedir', False) @property def extra_vars(self): @@ -183,7 +186,9 @@ class VariableManager: ) # default for all cases - basedirs = [self._loader.get_basedir()] + basedirs = [] + if self.safe_basedir: # avoid adhoc/console loading cwd + basedirs = [self._loader.get_basedir()] if play: # first we compile any vars specified in defaults/main.yml |