Skip to content

setup defines ansible_selinux as a boolean or as a dict #18692

@dagwieers

Description

@dagwieers
ISSUE TYPE
  • Bug Report
COMPONENT NAME

setup / facts

ANSIBLE VERSION

v2.2 and older

SUMMARY

Looking at the code https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts.py#L420 it defines ansible_selinux either as a boolean (False) when HAVE_SELINUX is False, but as a dictionary when HAVE_SELINUX is True.

That is bad design, it makes it harder to test for specific properties.
https://github.com/ansible/ansible/pull/18690/files#diff-6ef0fa8be07ffd2967bf772e9d792339R20

when: ansible_selinux is defined and ansible_selinux.status == 'enabled'

fails if it is a boolean, so I now have to rewrite this as:

when: ansible_selinux is defined and ansible_selinux != False and ansible_selinux.status == 'enabled'

and I won't be certain that this will not fail in some weird way (like maybe on some platform it returns True instead of a dictionary with status key).

Metadata

Metadata

Assignees

Labels

affects_2.2This issue/PR affects Ansible v2.2affects_2.3This issue/PR affects Ansible v2.3affects_2.4This issue/PR affects Ansible v2.4bugThis issue/PR relates to a bug.c:module_utils/factsselinux

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions