summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/fragments/include_vars_failed.yml2
-rw-r--r--lib/ansible/plugins/action/include_vars.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/changelogs/fragments/include_vars_failed.yml b/changelogs/fragments/include_vars_failed.yml
new file mode 100644
index 0000000000..8a3a5881f8
--- /dev/null
+++ b/changelogs/fragments/include_vars_failed.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - include_vars, properly initialize variable as there is corner case in which it can end up referenced and not defined
diff --git a/lib/ansible/plugins/action/include_vars.py b/lib/ansible/plugins/action/include_vars.py
index 07234537ac..7024002e5d 100644
--- a/lib/ansible/plugins/action/include_vars.py
+++ b/lib/ansible/plugins/action/include_vars.py
@@ -97,6 +97,7 @@ class ActionModule(ActionBase):
self._set_args()
results = dict()
+ failed = False
if self.source_dir:
self._set_dir_defaults()
self._set_root_dir()
@@ -164,13 +165,16 @@ class ActionModule(ActionBase):
)
self.source_dir = path.join(current_dir, self.source_dir)
+ def _log_walk(self, error):
+ self._display.vvv('Issue with walking through "%s": %s' % (to_native(error.filename), to_native(error)))
+
def _traverse_dir_depth(self):
""" Recursively iterate over a directory and sort the files in
alphabetical order. Do not iterate pass the set depth.
The default depth is unlimited.
"""
current_depth = 0
- sorted_walk = list(walk(self.source_dir))
+ sorted_walk = list(walk(self.source_dir, onerror=self._log_walk))
sorted_walk.sort(key=lambda x: x[0])
for current_root, current_dir, current_files in sorted_walk:
current_depth += 1