Note
This filter plugin is part of the community.general collection (version 10.7.3).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this filter plugin, see Requirements for details.
To use it in a playbook, specify: community.general.json_patch_recipe.
New in community.general 10.3.0
none value otherwise.The below requirements are needed on the local controller node that executes this filter.
This describes the input of the filter, the value before | community.general.json_patch_recipe.
Parameter | Comments |
|---|---|
Input any / required | A list or a dictionary representing a JSON object, or a string containing a JSON object. |
This describes positional parameters of the filter. These are the values positional1, positional2 and so on in the following example: input | community.general.json_patch_recipe(positional1, positional2, ...)
Parameter | Comments |
|---|---|
operations list / elements=dictionary / required | A list of JSON patch operations to apply. |
|
from string |
The source location for the copy and move operation. Mandatory for |
|
op string / required | |
|
path string / required |
JSON Pointer path to the target location (see RFC 6901). |
|
value any |
Value to use in the operation. Ignored for |
fail_test boolean | If Choices:
|
See also
JavaScript Object Notation (JSON) Patch
JavaScript Object Notation (JSON) Pointer
A Python library for applying JSON patches
- name: Apply a series of operations
ansible.builtin.debug:
msg: "{{ input | community.general.json_patch_recipe(operations) }}"
vars:
input: {}
operations:
- op: 'add'
path: '/foo'
value: 1
- op: 'add'
path: '/bar'
value: []
- op: 'add'
path: '/bar/-'
value: 2
- op: 'add'
path: '/bar/0'
value: 1
- op: 'remove'
path: '/bar/0'
- op: 'move'
from: '/foo'
path: '/baz'
- op: 'copy'
from: '/baz'
path: '/bax'
- op: 'copy'
from: '/baz'
path: '/bay'
- op: 'replace'
path: '/baz'
value: [10, 20, 30]
# => {"bar":[2],"bax":1,"bay":1,"baz":[10,20,30]}
Key | Description |
|---|---|
Return value any | A modified object or Returned: always |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/json_patch_recipe_filter.html