Ansible默認會提供一些內置的變量以實現一些特定的功能,我們稱之為魔法變量。
groups
ansible all -m debug -a 'var=groups'
group_names
ansible all -m debug -a 'var=group_names'
hostvars
ansible all -m debug -a 'var=hostvars'
ansible all -m debug -a 'var=hostvars["servera"]'
inventory_hostname
ansible all -m debug -a 'var=inventory_hostname'