Friends,
I am learning Ansible here and trying to apply what I am learning to one of my simple projects. I got stuck trying to format some strings. I getting the following error:
fatal: [localhost]: FAILED! => {"changed": false, "msg":
"AnsibleError: template error while templating string:
**unexpected ']', expected ')'**.
String:
cluster_name = "{{ terraform['%s' | format(env)].cluster_name }}"
credentials = "{{ terraform['%s' | format(env)].credentials }}"
initial_node_count = "{{ terraform['%s' | format(env]].initial_node_count }}
format(env)].project }}""}
...
This is how my jinja2 file looks like:
cluster_name = "{{ terraform['%s' | format(env)].cluster_name }}"
credentials = "{{ terraform['%s' | format(env)].credentials }}"
initial_node_count = "{{ terraform['%s' | format(env]].initial_node_count }}"
...
I want to generate strings like this terraform['testing'].credentials
when I run ansible-playbook site.yaml -e env=testing
and write them to a file. I can't figure out another way to get this done. Any Idea?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…