From 7a0ef069fa27aaecfda3d7311debf35f7777c969 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Fri, 14 Oct 2016 02:11:25 +0200 Subject: [PATCH] Convert name to bytes to compare it to bools On python 3, bools is a list of bytes: >>> rc,bools = selinux.security_get_boolean_names() >>> 'virt_use_nfs' in bools False >>> bools [b'abrt_anon_write', b'abrt_handle_event', ...] --- lib/ansible/modules/system/seboolean.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/system/seboolean.py b/lib/ansible/modules/system/seboolean.py index 1fc9ac2579b..4581c1333ef 100644 --- a/lib/ansible/modules/system/seboolean.py +++ b/lib/ansible/modules/system/seboolean.py @@ -71,7 +71,7 @@ def has_boolean_value(module, name): rc, bools = selinux.security_get_boolean_names() except OSError: module.fail_json(msg="Failed to get list of boolean names") - if name in bools: + if to_bytes(name) in bools: return True else: return False @@ -215,4 +215,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * +from ansible.module_utils._text import to_bytes main()