Skip to content

Instantly share code, notes, and snippets.

@dmsimard
Created May 17, 2016 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmsimard/e0b6ca95981ff85ded69bb22e33f06ea to your computer and use it in GitHub Desktop.
Save dmsimard/e0b6ca95981ff85ded69bb22e33f06ea to your computer and use it in GitHub Desktop.
{% macro display_result(result, hdr) %}
{% if result is mapping %}
{% if 'item' in result %}
<{{hdr}}>Item</{{hdr}}>
<pre>{{result.item|to_nice_json}}</pre>
{% endif %}
{% for attr in result.keys()|sort
if attr not in ['item', 'changed', 'stdout_lines'] %}
{% if result[attr]|default(False) %}
<{{hdr}}>{{attr|title}}</{{hdr}}>
{% if result[attr] is string %}
<pre>{{result[attr]}}</pre>
{% elif result[attr] is mapping or result[attr] is iterable%}
<pre>{{result[attr]|to_nice_json}}</pre>
{% else %}
<pre>{{result}}</pre>
{% endif %}
{% endif %}
{% endfor %}
{% else %}
<pre>{{result|to_nice_json}}</pre>
{% endif %}
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment