Getting ansible (not core) version in the playbook

53 views
Skip to first unread message

Piotr Kowalczyk

unread,
Sep 22, 2021, 4:15:26 AM9/22/21
to ansible...@googlegroups.com
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? :)

Best, 
Piotr Kowalczyk

-------------------------------
This document contains material that is confidential in CodiLime Sp. z o.o. DO NOT PRINT. DO NOT COPY. DO NOT DISTRIBUTE. If you are not the intended recipient of this document, be aware that any use, review, retransmission, distribution, reproduction or any action taken in reliance upon this message is strictly prohibited. If you received this in error, please contact the sender and he...@codilime.com. Return the paper copy, delete the material from all computers and storage media.

Dick Visser

unread,
Sep 22, 2021, 4:40:23 AM9/22/21
to ansible...@googlegroups.com
On Wed, 22 Sept 2021 at 10:15, 'Piotr Kowalczyk' via Ansible Project
<ansible...@googlegroups.com> wrote:

> 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? :)

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

--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Matt Martz

unread,
Sep 22, 2021, 9:09:04 AM9/22/21
to ansible...@googlegroups.com
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`.

--
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/CAL8fbwMYitPGF-u_HjMEn4%3DGSugyaty6mQs9r%2BzgN4Zf_y4zRw%40mail.gmail.com.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages