summaryrefslogtreecommitdiff
path: root/lib/ansible/playbook/play.py
diff options
context:
space:
mode:
authorRyan Brown <sb@ryansb.com>2017-10-09 11:27:50 -0400
committerSam Doran <sdoran@ansible.com>2017-10-09 11:27:50 -0400
commit958ad7726a5c495ae3699b8065414c34f9b4235a (patch)
tree4aca4bbde2e70137d5f19bb54407ab5ad044ca42 /lib/ansible/playbook/play.py
parentef72eda172266c8bd0d6b2826945fb14f58e6371 (diff)
downloadansible-958ad7726a5c495ae3699b8065414c34f9b4235a.tar.gz
Properly handle user selection of `None` as vars_files (#31313)
* Properly handle user selection of `None` as vars_files In a playbook, if a user has a playbook like: ``` - hosts: localhost connection: local vars_files: tasks: - .... ``` Then `vars_files` will be none, and cause a `TypeError` in vars-manager when it tries to iterate over them. To avoid this, I changed the getter to either send back the vars files from the user, or an empty list when the user passed `None`. * Only replace None with an empty list, not all falsey values * Catch error when vars_files isn't iterable * Move whole `for` loop into try/except and catch TypeError * Line length
Diffstat (limited to 'lib/ansible/playbook/play.py')
-rw-r--r--lib/ansible/playbook/play.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py
index 2fe4a9020d..ccd3b323a1 100644
--- a/lib/ansible/playbook/play.py
+++ b/lib/ansible/playbook/play.py
@@ -277,6 +277,8 @@ class Play(Base, Taggable, Become):
return self.vars.copy()
def get_vars_files(self):
+ if self.vars_files is None:
+ return []
return self.vars_files
def get_handlers(self):