0

My code:

 {%- set my_dict = {} %}
 {%- set my_dict['my_key'] = grains['id'] %}

Error message:

SaltRenderError: Jinja syntax error: expected token 'end of statement block', got '['; line x
carlfilip92
  • 73
  • 1
  • 2
  • 9

1 Answers1

1

Based on this answer, try this:

{%- set my_dict = {} %}
{%- set x=my_dict.__setitem__('my_key', grains['id']) %}

You can disregard the 'x' variable and keep using the dictionary.

Ahndwoo
  • 1,025
  • 4
  • 16