-1

There is a text file on the target node: /etc/debian_version:

8.6

In Ansible, I want to export this number to a variable, inside of a task. Is there some Ansible built-in module that can accomplish this in a simple manner?

I use the below Ansible versions with Python 3.7:

ansible==4.10.0
ansible-core==2.11.12
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
  • 2
    Yes, gather_facts and the setup module are already doing this. – U880D Nov 04 '22 at 06:59
  • 3
    This information is already in the gathered facts for your node. If you still want to read that file, see the `fetch` or `slurp` modules – Zeitounator Nov 04 '22 at 07:01
  • 1
    Can [Getting ... of the OS using Ansible facts](https://stackoverflow.com/questions/71034832/) give some insight? – U880D Nov 05 '22 at 08:08

1 Answers1

1

For posterity, the route I took was:

  1. Install lsb-release using apt
    • It was not previously installed on my Debian
  2. Then, thanks to Ansible facts:
when: ansible_facts["lsb"]["major_release"] | int == 11
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119