November 2017
Intermediate to advanced
266 pages
5h 34m
English
As we saw earlier, we can gather facts about a managed node using the following command:
ansible <hostname> -m setup
For example:
ansible localhost -m setup
Now, as we get the values back (called facts), we can refer to those system variables. Each system variable will hold a unique value based upon each of the managed node that was called under the hosts section:
- hosts: myrouters vars: mypath: "{{ base_path }}/etc"
The system variables can be called using the {{variable name}}, but in a playbook, they need to be referenced with double quotes.
Let us see an example where we get the value of hostname in our playbook:
- hosts: myrouters tasks: - debug: msg: "System {{ inventory_hostname }} has hostname as {{ ansible_nodename ...Read now
Unlock full access