I want to pretty print a registered object in ansible to help with debugging. How do I do it?
Asked
Active
Viewed 3.9k times
2 Answers
21
You also have to_nice_yaml
and to_nice_json
if you want to control the format itself. More details here.
13
You need to use with_dict and var= in your debug statement:
- tasks:
- name: build web node
nova_compute:
arguments: xyz
register: os_web_node
- debug: var={{ item }}
with_dict: os_web_node

J0hnG4lt
- 4,337
- 5
- 24
- 40
-
4Need to use jinja2 template around variable used with_dict otherwise it throws error "with_dict expects a dict". example: - debug: var={{ item }} with_dict: "{{ os_web_node }}" – Rayon Aug 29 '20 at 18:03