Skip to content

Instantly share code, notes, and snippets.

@markstos
Created August 7, 2024 15:14
Show Gist options
  • Save markstos/e3d7ada9ed2f4b90d3a97215185ca5d1 to your computer and use it in GitHub Desktop.
Save markstos/e3d7ada9ed2f4b90d3a97215185ca5d1 to your computer and use it in GitHub Desktop.
Ansible producing JSON vs Python-like output.
---
- 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