Getting ansible (not core) version in the playbook

Good morning,

Would you guys help me to understand how to get the Ansible correct version in the playbook?

I have newest Ansible:

(ansible) poe@lime:~$ pip3 freeze | grep ansible
ansible==4.6.0
ansible-core==2.11.5
(ansible) poe@lime:~$

But ansible_version displays core version instead of ansible:

(ansible) poe@lime:~$ ansible localhost -m debug -a ‘var=ansible_version.full’
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | SUCCESS => {
“ansible_version.full”: “2.11.5
}

Why is that so?

The same with ansible --version:

(ansible) poe@lime:~$ ansible --version | head -1
ansible [core 2.11.5]

The only command I’ve found which showing Ansible (not core) version instead is:

(ansible) poe@lime:~$ python -c ‘from ansible_collections.ansible_release import ansible_version; print(ansible_version)’
4.6.0

So the question is, is this expected? I mean, writing a playbook, I’d like to make sure that Ansible 4.6 is used (or not older). But ansible_version returns ansible core version - is something I should rely on instead? What’s going on here? :slight_smile:

Best,
Piotr Kowalczyk

I would use the above command and use the registered output.
Perhaps ansible would support this natively at some point.

To date, the decision has been that ansible-core does not discover or know anything about the ansible package. The ansible package just drops collection bundles in a location where ansible-core will look. The only way to get the ansible version is by the means you show, or by calling pip.