#something
keyA: A1: - bla - bla A2: bla bla A3: A3.1: bla A3.2: bla keyA: C1: - bla C2: bla bla C3: C3.1: bla keyB: B1: - bla - bla B2: bla bla B3: B3.1: bla B3.2: bla B3.3: bla B4: - bla - bla
- include_vars: file: "path to one of the YAML file" name: yamlVars
- template: src: updated.yaml.j2 dest: "path to that same file"
{% for key, value in yamlVars.iteritems() %}
# BEGIN BLOCK {{ key }}{{ value | to_nice_yaml }}# END BLOCK {{ key }}
{% endfor %}
# BEGIN BLOCK keyAA1: - bla - blaA2: bla blaA3: A3.1: bla A3.2: bla# END BLOCK keyA
# BEGIN BLOCK keyCC1: - blaC2: bla blaC3: C3.1: bla# END BLOCK keyC
# BEGIN BLOCK keyBB1: - bla - blaB2: bla blaB3: B3.1: bla B3.2: bla B3.3: blaB4: - bla - bla# END BLOCK keyB
# BEGIN BLOCK keyAkeyA: A1: - bla - bla A2: bla bla A3: A3.1: bla A3.2: bla# END BLOCK keyA
# BEGIN BLOCK keyCkeyC: C1: - bla C2: bla bla C3: C3.1: bla# END BLOCK keyC
# BEGIN BLOCK keyBkeyB: B1: - bla - bla B2: bla bla B3: B3.1: bla B3.2: bla B3.3: bla B4: - bla - bla# END BLOCK keyB
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9a06be57-73b2-4459-88f4-9ffb4a8ef4c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9a06be57-73b2-4459-88f4-9ffb4a8ef4c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/235c7a6c-27cd-4e39-90c2-454d57c56db1%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/235c7a6c-27cd-4e39-90c2-454d57c56db1%40googlegroups.com.
---
all:
vars:
randomkey: "1" # set this first to override
{% for k in inventory_data.key1.key2["key3-with-dashes"] -%}
{% set v = inventory_data.key1.key2["key3-with-dashes"][k] %}
{{ k | indent( width=1 )}}: {% if v is string %}{{ v | to_nice_json }}{% else %}{{ v | to_nice_json(indent=2) | indent( width=10, first=true) }}{% endif %}
{% endfor %}
- name: Create inventory file and populate
template:
src: localhost_inventory.yml.j2
dest: "{{ ansible_dir }}/inventory/localhost.yml"
mode: '0644'
owner: root
vars:
inventory_data: "{{ lookup('file','./ansible-inventory/settings/static/group1/hosts.yml') | from_yaml }}"