Provide the list of files that were included by include_vars

include_vars will now also return a key 'ansible_included_var_files'
which contains the list of files that were successfully loaded.
This is useful information and, amongst other things, a way for users
to know exactly what files were included when debugging their
playbooks.
This also allows us to improve the integration tests around
include_vars.
This commit is contained in:
David Moreau-Simard 2017-05-13 07:28:41 -04:00 committed by Brian Coca
parent 44bef1dc6b
commit 9fdd07fba8
3 changed files with 40 additions and 7 deletions

View file

@ -84,6 +84,7 @@ class ActionModule(ActionBase):
task_vars = dict()
self.show_content = True
self.included_files = []
# Validate arguments
dirs = 0
@ -141,6 +142,7 @@ class ActionModule(ActionBase):
result['failed'] = failed
result['message'] = err_msg
result['ansible_included_var_files'] = self.included_files
result['ansible_facts'] = results
result['_ansible_no_log'] = not self.show_content
@ -237,6 +239,7 @@ class ActionModule(ActionBase):
failed = True
err_msg = ('{0} must be stored as a dictionary/hash' .format(filename))
else:
self.included_files.append(filename)
results.update(data)
return failed, err_msg, results