In Ansible, there are three types of Special Variables.
A magic variable are variables that are built into Ansible. Following are the magic variables.
For example, let's say you have a playbook named version.yml and version.yml contains the following.
---
- hosts: localhost
tasks:
- debug:
var: ansible_version
...
You can run the version.yml playbook using the ansible-playbook command.
ansible-playbook version.yml
Which should return something like this.
TASK [debug]
ok: [localhost] => {
"ansible_version": {
"full": "2.9.27",
"major": 2,
"minor": 9,
"revision": 27,
"string": "2.9.27"
}
}