mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
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', ...]
This commit is contained in:
committed by
Matt Clay
parent
37008e1da1
commit
7a0ef069fa
@@ -71,7 +71,7 @@ def has_boolean_value(module, name):
|
|||||||
rc, bools = selinux.security_get_boolean_names()
|
rc, bools = selinux.security_get_boolean_names()
|
||||||
except OSError:
|
except OSError:
|
||||||
module.fail_json(msg="Failed to get list of boolean names")
|
module.fail_json(msg="Failed to get list of boolean names")
|
||||||
if name in bools:
|
if to_bytes(name) in bools:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
@@ -215,4 +215,5 @@ def main():
|
|||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
|
from ansible.module_utils._text import to_bytes
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user