debug Module

May 8, 2026 ยท View on GitHub

Print variables or strings for troubleshooting.

Parameters

ParameterDescriptionTypeRequiredDefault
msgContent to output, supports template syntax with filtersstringNo-
varVariable path to output, supports template syntax {{ .var }} or simple path .varstringNo-

Note: One of msg or var must be specified.

Examples

1. Print string

- name: debug string
  debug:
    msg: I'm {{ .name }}

When name is kubekey, output:

DEBUG:
I'm kubekey

2. Print with template filter

- name: debug with default filter
  debug:
    msg: "Name is {{ .name | default \"unknown\" }}"

When name is not defined, output:

DEBUG:
Name is unknown

3. Print map

- name: debug map
  debug:
    msg: >-
      {{ .product }}

When product is {"name":"kubekey"}, output similar to:

DEBUG:
{
    "name": "kubekey"
}

4. Print array

- name: debug array
  debug:
    msg: >-
      {{ .version }}

When version is ["1","2"], output similar to:

DEBUG:
[
    "1",
    "2"
]

5. Print variable using var field (template syntax)

- name: debug variable with template
  debug:
    var: "{{ .config.version }}"

When config.version is v1.0.0, output:

DEBUG:
"v1.0.0"

6. Print variable using var field (simple path)

- name: debug variable with path
  debug:
    var: ".config.version"

When config.version is v1.0.0, output:

DEBUG:
"v1.0.0"

7. Print nested variable

- name: debug nested variable
  debug:
    var: ".data.level1.level2"

When data.level1.level2 is value, output:

DEBUG:
"value"