Merge pull request #1612 from dhozac/play-vars-list

Make parameterized playbook includes work with vars as a list
pull/1648/head
Michael DeHaan 12 years ago
commit 7a48525357

@ -166,7 +166,10 @@ class PlayBook(object):
for p in plays: for p in plays:
if 'vars' not in p: if 'vars' not in p:
p['vars'] = {} p['vars'] = {}
p['vars'].update(incvars) if isinstance(p['vars'], dict):
p['vars'].update(incvars)
elif isinstance(p['vars'], list):
p['vars'].extend([dict(k=v) for k,v in incvars.iteritems()])
accumulated_plays.extend(plays) accumulated_plays.extend(plays)
play_basedirs.extend(basedirs) play_basedirs.extend(basedirs)

@ -114,6 +114,7 @@ class TestPlaybook(unittest.TestCase):
def _run(self, test_playbook, host_list='test/ansible_hosts'): def _run(self, test_playbook, host_list='test/ansible_hosts'):
''' run a module and get the localhost results ''' ''' run a module and get the localhost results '''
# This ensures tests are independent of eachother # This ensures tests are independent of eachother
global EVENTS
ansible.playbook.SETUP_CACHE.clear() ansible.playbook.SETUP_CACHE.clear()
EVENTS = [] EVENTS = []
@ -202,7 +203,8 @@ class TestPlaybook(unittest.TestCase):
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True) assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
assert len(EVENTS) == 60 print "len(EVENTS) = %d" % len(EVENTS)
assert len(EVENTS) == 26
def test_includes(self): def test_includes(self):
pb = os.path.join(self.test_dir, 'playbook-includer.yml') pb = os.path.join(self.test_dir, 'playbook-includer.yml')
@ -215,7 +217,7 @@ class TestPlaybook(unittest.TestCase):
"localhost": { "localhost": {
"changed": 0, "changed": 0,
"failures": 0, "failures": 0,
"ok": 5, "ok": 10,
"skipped": 0, "skipped": 0,
"unreachable": 0 "unreachable": 0
} }

@ -3,3 +3,10 @@
gather_facts: False gather_facts: False
tasks: tasks:
- action: debug msg="$variable" - action: debug msg="$variable"
- hosts: all
vars:
- ugly: var
gather_facts: False
tasks:
- action: debug msg="$variable"

Loading…
Cancel
Save