From f11f6595cc7a9f90aa8b1812d32da3fab5bd3d12 Mon Sep 17 00:00:00 2001 From: Anubhav Chakraborty <47817745+coderfool@users.noreply.github.com> Date: Sat, 24 Apr 2021 15:50:11 +0530 Subject: [PATCH] convert string returned by plugin to unicode (#2329) * convert string returned by plugin to unicode * add changelog fragment * fix changelog format * fix changelog format yet again Co-authored-by: Anubhav Chakraborty --- changelogs/fragments/2329-hiera-lookup-plugin-return-type.yaml | 2 ++ plugins/lookup/hiera.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/2329-hiera-lookup-plugin-return-type.yaml diff --git a/changelogs/fragments/2329-hiera-lookup-plugin-return-type.yaml b/changelogs/fragments/2329-hiera-lookup-plugin-return-type.yaml new file mode 100644 index 0000000000..4cced727a2 --- /dev/null +++ b/changelogs/fragments/2329-hiera-lookup-plugin-return-type.yaml @@ -0,0 +1,2 @@ +bugfixes: + - hiera lookup plugin - converts the return type of plugin to unicode string (https://github.com/ansible-collections/community.general/pull/2329). diff --git a/plugins/lookup/hiera.py b/plugins/lookup/hiera.py index 1ce82d7bd6..899820191a 100644 --- a/plugins/lookup/hiera.py +++ b/plugins/lookup/hiera.py @@ -63,6 +63,7 @@ import os from ansible.plugins.lookup import LookupBase from ansible.utils.cmd_functions import run_cmd +from ansible.module_utils._text import to_text ANSIBLE_HIERA_CFG = os.getenv('ANSIBLE_HIERA_CFG', '/etc/hiera.yaml') ANSIBLE_HIERA_BIN = os.getenv('ANSIBLE_HIERA_BIN', '/usr/bin/hiera') @@ -78,7 +79,7 @@ class Hiera(object): rc, output, err = run_cmd("{0} -c {1} {2}".format( ANSIBLE_HIERA_BIN, ANSIBLE_HIERA_CFG, hiera_key[0])) - return output.strip() + return to_text(output.strip()) class LookupModule(LookupBase):