From 5752d2a850cb797ba919f5c68027f0a73869b69a Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Tue, 13 Nov 2012 12:09:42 +0100 Subject: [PATCH 1/2] Fix lookup plugin test properly --- test/TestPlayBook.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/TestPlayBook.py b/test/TestPlayBook.py index 9ff679973d6..d66d56a417d 100644 --- a/test/TestPlayBook.py +++ b/test/TestPlayBook.py @@ -114,6 +114,7 @@ class TestPlaybook(unittest.TestCase): def _run(self, test_playbook, host_list='test/ansible_hosts'): ''' run a module and get the localhost results ''' # This ensures tests are independent of eachother + global EVENTS ansible.playbook.SETUP_CACHE.clear() EVENTS = [] @@ -202,7 +203,8 @@ class TestPlaybook(unittest.TestCase): 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): pb = os.path.join(self.test_dir, 'playbook-includer.yml') From eebbbd3f0e368ecd1d9c9e6f45f349a8bc09f04a Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Tue, 13 Nov 2012 12:12:18 +0100 Subject: [PATCH 2/2] Make parameterized playbook includes work with vars as a list Fixes #1610. --- lib/ansible/playbook/__init__.py | 5 ++++- test/TestPlayBook.py | 2 +- test/playbook-included.yml | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index f26715dd93d..ba3e7418ae2 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -166,7 +166,10 @@ class PlayBook(object): for p in plays: if 'vars' not in p: 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) play_basedirs.extend(basedirs) diff --git a/test/TestPlayBook.py b/test/TestPlayBook.py index d66d56a417d..d67779b6731 100644 --- a/test/TestPlayBook.py +++ b/test/TestPlayBook.py @@ -217,7 +217,7 @@ class TestPlaybook(unittest.TestCase): "localhost": { "changed": 0, "failures": 0, - "ok": 5, + "ok": 10, "skipped": 0, "unreachable": 0 } diff --git a/test/playbook-included.yml b/test/playbook-included.yml index 4f96e30a4a8..d6cb3530a1c 100644 --- a/test/playbook-included.yml +++ b/test/playbook-included.yml @@ -3,3 +3,10 @@ gather_facts: False tasks: - action: debug msg="$variable" + +- hosts: all + vars: + - ugly: var + gather_facts: False + tasks: + - action: debug msg="$variable"