Bootstrap FreeKB - Ansible - Determine Ansible version
Ansible - Determine Ansible version

Updated:   |  Ansible articles

The ansible ad-hoc command can be used to list the version of Ansible, the location of the Ansible configuration file, and the version of Python.

ansible --version

 

Something like this should be returned if you are using a very old version of Ansible that has reached end of life.

ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/your_username/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible playbook module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, mm dd yyyy, hh:mm:ss) [GCC 4.8.5 yyyymmdd (Red Hat 4.8.5-39)]

 

On the other hand, if "core" is returned this means you are using ansible-core, which is a good thing.

ansible [core 2.16.4]
  config file = None
  configured module search path = ['/home/john.doe/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/ansible-core/v2_16_4/lib/python3.12/site-packages/ansible
  ansible collection location = /home/john.doe/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.0 (main, Dec 22 2023, 02:43:27) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] (/usr/local/ansible-core/v2_16_4/lib/python3.12)
  jinja version = 3.1.3
  libyaml = True

 

Or let's say you have the following playbook, which uses the ansible_version fact.

---
- hosts: all
  tasks:
  ansible.builtin.debug:
    var: ansible_version
...

 

Something like this should be returned.

ok: [server1] => {
    "ansible_version": {
        "full": "2.19.0",
        "major": 2,
        "minor": 19,
        "revision": 0,
        "string": "2.19.0"
    }
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 00104a in the box below so that we can be sure you are a human.