From 32b9ea689acefa0a534266237c885e2827e84cc7 Mon Sep 17 00:00:00 2001 From: Brad Olson Date: Tue, 29 May 2012 10:09:38 -0400 Subject: [PATCH] Test for play.vars_files == None, avoiding nasty traceback. Ignores for now. Could warn. Playbook test for no vars_files with len(), but that excepts if play.vars_files==None, as can happen when there's a vars_files section with no vars files listed. What is the ansible way: ignore, warn, or fail with message (instead of traceback)? --- lib/ansible/playbook/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index c467ba3397..ee20fdacfd 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -280,8 +280,9 @@ class PlayBook(object): rc = self._do_setup_step(play) # pattern, vars, user, port, sudo, sudo_user, transport, None) # now with that data, handle contentional variable file imports! - if len(play.vars_files) > 0: + if play.vars_files and len(play.vars_files) > 0: rc = self._do_setup_step(play, play.vars_files) + #else: warn "You have a vars_files section but didn't state any vars files?? # run all the top level tasks, these get run on every node for task in play.tasks():