Bootstrap FreeKB - Ansible - ansible_distribution_release fact
Ansible - ansible_distribution_release fact

Updated:   |  Ansible articles

The ansible_distribution_release magic variable will return the Operating Systme Release of a managed node (e.g. the target system). Refer to run tasks on the control node if you want to run this on your control node.

For example, let's say you have the following playbook. 

- hosts: all
    - debug:
        var: ansible_distribution_releaseĀ 


If you get the following output, the gather_facts module may be set to false. gather_facts must be set to true, or not defined at all in your playbook, as gather_facts is true by default.

TASK [debug]
fatal: []: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible_distribution_releaseĀ ' is undefined\n\nThe error appears to be in 'testing.yml': line 8, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - debug:\n      ^ here\n"}


Running this playbook should return the following.

TASK [debug]
ok: [] => {
    "msg: "Red Hat Linux 8.8 (Ootpa)"


Did you find this article helpful?

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


Add a Comment

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