Always add vars to a play.

A play without vars section would fail to use variables given in an include. They would be added to the dict returned by play.get, but the dict would not be added to the play.
This commit is contained in:
Jeroen Hoekx 2012-04-03 17:22:45 +02:00
parent 02d5e831ce
commit e38ae18627

View file

@ -91,8 +91,9 @@ class PlayBook(object):
def _get_vars(self, play, dirname): def _get_vars(self, play, dirname):
''' load the vars section from a play ''' ''' load the vars section from a play '''
if play.get('vars') is None:
vars = play.get('vars', {}) play['vars'] = {}
vars = play['vars']
if type(vars) != dict: if type(vars) != dict:
raise errors.AnsibleError("'vars' section must contain only key/value pairs") raise errors.AnsibleError("'vars' section must contain only key/value pairs")
vars_prompt = play.get('vars_prompt', {}) vars_prompt = play.get('vars_prompt', {})