Ansible instructions to merge two json files.
Assumes files: original.json, merge.json and new.json
---
- name: get content of original file
slurp:
src: "original.json"
register: original_config
ignore_errors: yes
- name: convert content to json and load merge json
set_fact:
original_json: "{{ original_config.content|default('e30=') | b64decode | from_json }}"
merge_json: "{{ lookup('file', merge.json' ) | from_json }}"
- name: merge content
copy:
content: "{{ original_json | combine(merge_json) | to_nice_json(indent=2) }}"
dest: "new.json"