From 439a385215fb11766a83542e2ee00d1e66b5b5a7 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 18 Feb 2016 15:17:42 -0600 Subject: [PATCH] Catch TypeError on join, and if caught just return a single item, or a list of many --- lib/ansible/template/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index bec34f81aa..edb34bb4be 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -420,7 +420,13 @@ class Templar: if wantlist: ran = wrap_var(ran) else: - ran = UnsafeProxy(",".join(ran)) + try: + ran = UnsafeProxy(",".join(ran)) + except TypeError: + if isinstance(ran, list) and len(ran) == 1: + ran = wrap_var(ran[0]) + else: + ran = wrap_var(ran) return ran else: