# Getting the version of an Ansible Galaxy role

**URL:** <https://forum.ansible.com/t/getting-the-version-of-an-ansible-galaxy-role/32971>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [May 19, 2020, 1:22pm UTC](https://forum.ansible.com/t/getting-the-version-of-an-ansible-galaxy-role/32971 "2020-05-19T13:22:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pablo\_Baeyens](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@Pablo\_Baeyens](https://forum.ansible.com/u/Pablo_Baeyens)\
**Post date:** [May 19, 2020, 1:22pm UTC](https://forum.ansible.com/t/getting-the-version-of-an-ansible-galaxy-role/32971/1 "2020-05-19T13:22:30Z")

</div>

Hi,

I want to know the version of a role (from Galaxy) from inside that role ([versions](https://galaxy.ansible.com/docs/contributing/version.html) correspond to git tags in the source repo).

Is there any special variable I can get with the version of a role being executed?  
Any other alternative method of getting this information would also work.

Thank you in advance,  
Pablo

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 21, 2020, 3:34am UTC](https://forum.ansible.com/t/getting-the-version-of-an-ansible-galaxy-role/32971/2 "2020-05-21T03:34:58Z")

</div>

nothing internal, you'll have to shell out to use `ansilbe-galaxy info  
\<role\> --offline`

---

<div class="post-metadata">

**Author:** ![Pablo\_Baeyens](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@Pablo\_Baeyens](https://forum.ansible.com/u/Pablo_Baeyens)\
**Post date:** [May 22, 2020, 11:25am UTC](https://forum.ansible.com/t/getting-the-version-of-an-ansible-galaxy-role/32971/3 "2020-05-22T11:25:56Z")

</div>

Okay, thank you for your help!

I don’t think it is the best approach since the output from that command seems meant for humans to read and so there are no guarantees that it will remain as is in future versions, but there does not seem to be an alternative.

Pablo

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 3, 2020, 2:15pm UTC](https://forum.ansible.com/t/getting-the-version-of-an-ansible-galaxy-role/32971/4 "2020-06-03T14:15:17Z")

</div>

if they are your roles a \_rolname\_version in vars/main.yml would be a  
good workaround.
