Created
August 7, 2024 15:14
-
-
Save markstos/e3d7ada9ed2f4b90d3a97215185ca5d1 to your computer and use it in GitHub Desktop.
Ansible producing JSON vs Python-like output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
vars: | |
main: | |
Foo: false | |
aBool: false | |
myLoop: | |
- override: | |
Foo: false | |
aBool: true | |
- override: | |
Foo: true | |
aBool: false | |
tasks: | |
- name: Test with debug module | |
loop: "{{ myLoop }}" | |
debug: | |
msg: '{ "outer":{{ main | combine(item.override, recursive=True) | to_json }} }' | |
- name: Test with copy module | |
loop: "{{ myLoop }}" | |
copy: | |
content: '{ "outer":{{ main | combine(item.override, recursive=True) | to_json }} }' | |
dest: /tmp/test.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment