From 4a7940c562635d39496364596b86d0ff9d230766 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 10 Jul 2018 09:41:33 -0400 Subject: [PATCH] Ensure string types (#42362) * actually enforce string types * unquote after its text * fixed incorrect template type * fixing string showed error in template typing --- lib/ansible/config/manager.py | 5 ++++- lib/ansible/plugins/action/template.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index c31f3ab508..c308c3810d 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -99,7 +99,10 @@ def ensure_type(value, value_type, origin=None): value = value.split(',') value = [resolve_path(x, basedir=basedir) for x in value] - # defaults to string types + elif value_type in ('str', 'string'): + value = unquote(to_text(value, errors='surrogate_or_strict')) + + # defaults to string type elif isinstance(value, string_types): value = unquote(value) diff --git a/lib/ansible/plugins/action/template.py b/lib/ansible/plugins/action/template.py index c4e802a756..5cdb2f5271 100644 --- a/lib/ansible/plugins/action/template.py +++ b/lib/ansible/plugins/action/template.py @@ -89,7 +89,7 @@ class ActionModule(ActionBase): for b_type in ('force', 'follow', 'trim_blocks'): value = locals()[b_type] - value = ensure_type(value, 'string') + value = ensure_type(value, 'boolean') if value is not None and not isinstance(value, bool): raise AnsibleActionFail("%s is expected to be a boolean, but got %s instead" % (b_type, type(value))) locals()[b_type] = value