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:

  1. Facts gathered about the host: everything Ansible collects, such as IP addresses, disk space and so on.
  2. Facts from host vars and group vars: variables defined for the host in host_vars or group_vars.
  3. Facts defined in the role: for example, in defaults/main.yaml.
  4. 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: