0
Ich habe eine json host_names.json Datei mit der Struktur vonansible jinja2 Vorlage aus JSON-Datei
{
"host1": "run on host 1",
"host2": "run on host 2",
"host3": "run on host 3"
}
Im selben Verzeichnis habe ich ein Textbuch run.yml
---
- name: Run this
connection: local
tasks:
- name: Template
src: "template.j2"
dest: "/my_dest/my_file.txt
Ich würde Wie sieht die Vorlage so aus:
#########
# host1 #
#########
run on host 1
end
#########
# host2 #
#########
run on host 2
end
#########
# host3 #
#########
run on host 3
end
Wie würde meine Vorlage dafür aussehen? Dies ist, was zur Zeit ich habe
{% for a, b in host_names %}
###########
# {{ a }} #
###########
{{ b }}
end
{% endfor %}