Hi,
I’m currently writing an Ansible playbook, and I can’t seem to wrap my head around one small problem.
I’m trying to check if the vagrant
package is installed in version 2.4.1
. As far as I can tell, I need the package_facts
module to do this.
I’m testing this in my playbook like this:
- name: Gather package facts
ansible.builtin.package_facts:
manager: rpm
- name: Print Vagrant package facts
ansible.builtin.debug:
var: ansible_facts.packages['vagrant']
When I run the playbook, this is the output:
TASK [apps_vagrant : Print Vagrant package facts] ******************************
ok: [localhost] => {
"ansible_facts.packages['vagrant']": [
{
"arch": "x86_64",
"epoch": 0,
"name": "vagrant",
"release": "1",
"source": "rpm",
"version": "2.4.1"
}
]
}
Now here’s the question: how do I access only the version? I tried ansible_facts.packages['vagrant'].version
, ansible_facts.packages.vagrant.version
and some other combinations, but all I get is VARIABLE IS NOT DEFINED
. I guess this is a no-brainer, but I’m stuck anyway.
Any suggestions ?