From 478283f571bd52cbae3fdaac93582ec233b37b9e Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Fri, 26 Aug 2016 18:48:27 +0200 Subject: [PATCH] Do not convert Nonetype to "None" (#17261) If someone use a task with a empty name like this: - name: command: true This will result in displaying 'None' as a task name instead of 'command'. --- lib/ansible/plugins/strategy/free.py | 4 ++-- lib/ansible/plugins/strategy/linear.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/plugins/strategy/free.py b/lib/ansible/plugins/strategy/free.py index 89287c49ab3..f6b4f222017 100644 --- a/lib/ansible/plugins/strategy/free.py +++ b/lib/ansible/plugins/strategy/free.py @@ -26,7 +26,7 @@ from ansible.playbook.included_file import IncludedFile from ansible.plugins import action_loader from ansible.plugins.strategy import StrategyBase from ansible.template import Templar -from ansible.compat.six import text_type +from ansible.utils.unicode import to_unicode try: from __main__ import display @@ -109,7 +109,7 @@ class StrategyModule(StrategyBase): display.debug("done getting variables") try: - task.name = text_type(templar.template(task.name, fail_on_undefined=False)) + task.name = to_unicode(templar.template(task.name, fail_on_undefined=False), nonstring='empty') display.debug("done templating") except: # just ignore any errors during task name templating, diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index 50028fbe1c4..dc2b1a03207 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -19,7 +19,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible.compat.six import iteritems, text_type +from ansible.compat.six import iteritems from ansible.errors import AnsibleError from ansible.executor.play_iterator import PlayIterator @@ -238,7 +238,7 @@ class StrategyModule(StrategyBase): saved_name = task.name display.debug("done copying, going to template now") try: - task.name = text_type(templar.template(task.name, fail_on_undefined=False)) + task.name = to_unicode(templar.template(task.name, fail_on_undefined=False), nonstring='empty') display.debug("done templating") except: # just ignore any errors during task name templating,