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 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. On Thu, Jan 5, 2023 at 11:28 AM Stephen Maher <[email protected]> wrote: > 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 < > [email protected]> wrote: > > 'ansible_python_version' is undefined > > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/2141C585-3C8E-4CA2-BF39-209B12E3C4A0%40gmail.com > <https://groups.google.com/d/msgid/ansible-project/2141C585-3C8E-4CA2-BF39-209B12E3C4A0%40gmail.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CALF5A-%2Bva0LRxQg8E4%3DS0im6avY-xXPjAx_hjJ_RJL%2B-RUqksg%40mail.gmail.com.
