rhel-system-roles.selinux Fatal error

120 views
Skip to first unread message

Kannan

unread,
Jan 5, 2023, 4:28:01 AM1/5/23
to Ansible Project
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

Rowe, Walter P. (Fed)

unread,
Jan 5, 2023, 7:12:02 AM1/5/23
to ansible...@googlegroups.com
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
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d5dd49f4-1cda-4272-afcd-85404c5bdf1bn%40googlegroups.com.

Stephen Maher

unread,
Jan 5, 2023, 11:28:05 AM1/5/23
to ansible...@googlegroups.com
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] *****************************************************************************************************************************************************************************************
ok: [localhost] => {
    "ansible_python_version": "VARIABLE IS NOT DEFINED!"
}

TASK [gather some facts] *********************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Do we have ansible_python_version] *****************************************************************************************************************************************************************************************
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
---

- hosts: localhost
  gather_facts: false

  tasks:
    - name: Do we have ansible_python_version
      debug: var=ansible_python_version

    - name: gather some facts
      setup:
        gather_subset: min

    - name: Do we have ansible_python_version
      debug: var=ansible_python_version


On 5 Jan 2023, at 12:11, 'Rowe, Walter P. (Fed)' via Ansible Project <ansible...@googlegroups.com> wrote:

'ansible_python_version' is undefined

Richard Megginson

unread,
Jan 5, 2023, 7:40:57 PM1/5/23
to ansible...@googlegroups.com
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:
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages