# rhel-system-roles.selinux Fatal error

**URL:** <https://forum.ansible.com/t/rhel-system-roles-selinux-fatal-error/37525>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [January 5, 2023, 9:28am UTC](https://forum.ansible.com/t/rhel-system-roles-selinux-fatal-error/37525 "2023-01-05T09:28:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kannan1](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@Kannan1](https://forum.ansible.com/u/Kannan1)\
**Post date:** [January 5, 2023, 9:28am UTC](https://forum.ansible.com/t/rhel-system-roles-selinux-fatal-error/37525/1 "2023-01-05T09:28:01Z")

</div>

Dear Team,

I am new to Ansible and i am getting the following erro while running " rhel-system-roles.selinux". Could you please help to resolve this error.

Environment:

RHEL- 9

Ansible core - 2.12.2

python version = 3.9.10

TASK [rhel-system-roles.selinux : Install SELinux python2 tools] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [ss1]: FAILED! =\> {“msg”: “The conditional check ‘ansible\_python\_version is version(‘3’, ‘\<’)’ failed. The error was: error while evaluating conditional (ansible\_python\_version is version(‘3’, ‘\<’)): ‘ansible\_python\_version’ is undefined\n\nThe error appears to be in ‘/usr/share/ansible/roles/rhel-system-roles.selinux/tasks/main.yml’: line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n—\n- name: Install SELinux python2 tools\n ^ here\n”}

Thanks & Regards,  
Kannan Ravi

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [January 5, 2023, 12:11pm UTC](https://forum.ansible.com/t/rhel-system-roles-selinux-fatal-error/37525/2 "2023-01-05T12:11:36Z")

</div>

> The error was: error while evaluating conditional (ansible\_python\_version is version(‘3’, ‘\<’)): ‘ansible\_python\_version’ is undefined

I don’t know why that would not be defined, but that is causing your error.

Walter

---

<div class="post-metadata">

**Author:** ![mahespth](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mahespth/32/252_2.png) [@mahespth](https://forum.ansible.com/u/mahespth)\
**Post date:** [January 5, 2023, 4:27pm UTC](https://forum.ansible.com/t/rhel-system-roles-selinux-fatal-error/37525/3 "2023-01-05T16:27:46Z")

</div>

Hi,

this var needs gather\_facts to be true or setup to be called with at least ‘min’ level of facts.

STEPHENs-iMac:ansible mahespth$ ansible-playbook ansible\_python\_version

[WARNING]: No inventory was parsed, only implicit localhost is available  
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Do we have ansible\_python\_version] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*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\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“ansible\_python\_version”: “3.6.5”  
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

STEPHENs-iMac:ansible mahespth$ cat ansible\_python\_version

---

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [January 6, 2023, 12:40am UTC](https://forum.ansible.com/t/rhel-system-roles-selinux-fatal-error/37525/4 "2023-01-06T00:40:16Z")

</div>

What version of rhel-system-roles are you using? Current versions of the role have logic to explicitly call `setup` to get the facts required by the role:  
[https://github.com/linux-system-roles/selinux/blob/master/tasks/set\_facts\_packages.yml#L2](https://github.com/linux-system-roles/selinux/blob/master/tasks/set_facts_packages.yml#L2)  
and python\_version is among the facts:

# ansible\_facts required by the role

\_\_selinux\_required\_facts:

- distribution
- distribution\_major\_version
- python\_version

Since you are using rhel-system-roles, this means you are a RHEL and/or an Ansible customer.  
If you installed the rpm, use rpm -q rhel-system-roles  
If you installed from AutomatIon Hub, use ansible-galaxy collection list or something like that.
