From 01b47a8a1f3b1ba9f71d8f407a3dde788c6909cd Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 24 Apr 2021 12:51:52 +0200 Subject: [PATCH] convert string returned by plugin to unicode (#2329) (#2338) * convert string returned by plugin to unicode * add changelog fragment * fix changelog format * fix changelog format yet again Co-authored-by: Anubhav Chakraborty (cherry picked from commit f11f6595cc7a9f90aa8b1812d32da3fab5bd3d12) Co-authored-by: Anubhav Chakraborty <47817745+coderfool@users.noreply.github.com> --- 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 b5dca4bae7..e3adf3d9b9 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):