diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 8646bcd8b1e..dcb67bdc0de 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -194,7 +194,7 @@ class Play(object): task_vars['_original_file'] = original_file if 'include' in x: - tokens = shlex.split(x['include']) + tokens = shlex.split(str(x['include'])) items = [''] included_additional_conditions = list(additional_conditions) for k in x: diff --git a/test/TestPlayBook.py b/test/TestPlayBook.py index 0445158b167..e2dfcd8634c 100644 --- a/test/TestPlayBook.py +++ b/test/TestPlayBook.py @@ -211,6 +211,27 @@ class TestPlaybook(unittest.TestCase): assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True) + def test_task_includes(self): + pb = os.path.join(self.test_dir, 'task-includer.yml') + actual = self._run(pb) + + # if different, this will output to screen + print "**ACTUAL**" + print utils.jsonify(actual, format=True) + expected = { + "localhost": { + "changed": 0, + "failures": 0, + "ok": 1, + "skipped": 0, + "unreachable": 0 + } + } + print "**EXPECTED**" + print utils.jsonify(expected, format=True) + + assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True) + def test_playbook_vars(self): test_callbacks = TestCallbacks() playbook = ansible.playbook.PlayBook( diff --git a/test/task-included.yml b/test/task-included.yml new file mode 100644 index 00000000000..0c68a120741 --- /dev/null +++ b/test/task-included.yml @@ -0,0 +1,2 @@ +--- +- action: debug msg="$internal" diff --git a/test/task-includer.yml b/test/task-includer.yml new file mode 100644 index 00000000000..b728827f72b --- /dev/null +++ b/test/task-includer.yml @@ -0,0 +1,9 @@ +--- +- hosts: all + connection: local + gather_facts: no + vars: + - internal: xyz + + tasks: + - include: task-included.yml internal=$internal