Assign json file to a variable inside loop jinja2 ansible

4/5/2019

I am trying to assign a json file to a variable inside loop in ansible using --set-string and then run helm upgrade command. But it gives -

This command needs 2 arguments: release name, chart path\nError: plugin \"tiller\" exited with error" error.

  {% for file in v.value.files %}
  --set-string config[{{ loopOut.index0 }}].files[{{ loop.index0 }}].name={{ file }}
  {% set args = args|combine(v.value.args) %}
  --set-string config[{{ loopOut.index0 }}].files[{{ loop.index0 }}].value=
  {{ lookup('file','../files/initData.json')| from_json }}
  {% endfor %}

where loopOut is outer loop variable inside which I have this current loop. What am I doing wrong here? I even tried to put

 "{{ lookup('file','../files/initData.json')| from_json }}" in quotes

But this also does not help.

-- supriya
ansible
jinja2
jinja2-cli
kubernetes-helm

0 Answers