mensik.net
Posts

The ansible module debug outputs variables assotiated with a specific host.

- name: Show all variables/facts known for a host
  debug:
    var: hostvars['myserver.example.com']

So it displays:

  1. Facts they gathered about the host: all things Ansible gathers about the host. Things like IP addresses, disk space etc.
  2. Facts from host vars and group vars: if we have variables defined for the specified host in host_vars or group_vars, they are displayed too.
  3. Facts defined in the role: for example in defaults/main.yaml
  4. All other variables that set during the execution of the playbook: variables for the playbook, variables specified on the commandline or facts registered during the exectution of the playbook.

Example how to specify a variable on the command line:

ansible-playbook example_playbook.yml -e "example_variable=example_value"
© mensik.net 2024