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):