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.