I\'m using Ansible to automate some configuration steps for my application VM, but having difficult to insert a new key-value to an existing json file on the remote host.
ilias-sp's solution is great!
In my case, it lacked the case when we may have to create a base json file. So I had to add this task in the beginning of the play:
- name: Ensure json file exists copy: content: "{}" dest: /tmp/var.json force: false