Skip to content

Instantly share code, notes, and snippets.

@zipkid

zipkid/debug Secret

Created April 10, 2015 12:52
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 zipkid/6796e3479fee0d7ea0ff to your computer and use it in GitHub Desktop.
Save zipkid/6796e3479fee0d7ea0ff to your computer and use it in GitHub Desktop.
[DEBUG ] Rendered data from file: /var/cache/salt/minion/files/base/x.sls:
test:
grains.present:
- value: '{"key1": ["val1-1", "val1-2"], "key2": ["val2-1", "val2-2"]}'
# {"key1": ["val1-1", "val1-2"], "key2": ["val2-1", "val2-2"]}
# {u'key2': [u'val2-1', u'val2-2'], u'key1': [u'val1-1', u'val1-2']}
# key2
# key1
/root/x:
file.managed:
- source: salt://x.tmpl
- template: jinja
- context:
g: {u'key2': [u'val2-1', u'val2-2'], u'key1': [u'val1-1', u'val1-2']}
[root@saltmaster01 ~]# cat x
u'key2'
...:
- u'val2-1'
...
- u'val2-2'
...
u'key1'
...:
- u'val1-1'
...
- u'val1-2'
...
{% set t = { 'key1': ['val1-1', 'val1-2'], 'key2': [ 'val2-1', 'val2-2' ] } %}
test:
grains.present:
- value: '{{ t|json }}'
{% set g = salt['grains.get']('test', '{}') %}
# {{ g }}
{% set g_d = g|load_json %}
# {{ g_d }}
{% for x in g_d %}
# {{ x }}
{% endfor %}
/root/x:
file.managed:
- source: salt://x.tmpl
- template: jinja
- context:
g: {{ g_d }}
{% for k, v in g.items() %}
{{ k|yaml }}:
{%- for d in v %}
- {{ d|yaml }}
{%- endfor %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment