Using Ansible's debug Module
The Ansible debug module prints the contents of variables.
For example, a variable tied to a specific host:
- name: Show all variables/facts known for a host
debug:
var: hostvars['myserver.example.com']
verbosity: 1 # default verbosity is 0, max verbosity is 4
This displays:
- Facts gathered about the host: everything Ansible collects, such as IP addresses, disk space and so on.
- Facts from host vars and group vars: variables defined for the host in
host_varsorgroup_vars. - Facts defined in the role: for example, in
defaults/main.yaml. - Other variables set during the run: playbook variables, variables passed on the command line, and facts registered during execution.
Passing a variable on the command line:
ansible-playbook example_playbook.yml -e "example_variable=example_value"
Tags: