ansible.posix.patch module – Apply patch files using the GNU patch tool
Note
This module is part of the ansible.posix collection (version 1.5.4).
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 ansible.posix
.
To use it in a playbook, specify: ansible.posix.patch
.
New in ansible.posix 1.0.0
Synopsis
- Apply patch files using the GNU patch tool.
Note
This module has a corresponding action plugin.
Parameters
Parameter | Comments |
---|---|
backup boolean | Passes Choices:
|
basedir path | Path of a base directory in which the patch file will be applied. May be omitted when |
binary boolean | Setting to Line endings of src and dest must match. If set to Choices:
|
dest aliases: originalfile path | Path of the file on the remote machine to be patched. The names of the files to be patched are usually taken from the patch file, but if there’s just one file to be patched it can specified with this option. |
ignore_whitespace boolean | Setting to Choices:
|
remote_src boolean | If Choices:
|
src aliases: patchfile path / required | Path of the patch file as accepted by the GNU patch tool. If |
state string | Whether the patch should be applied or reverted. Choices:
|
strip integer | Number that indicates the smallest prefix containing leading slashes that will be stripped from each file name found in the patch file. For more information see the strip parameter of the GNU patch tool. Default: |
Notes
Note
- This module requires GNU patch utility to be installed on the remote host.
Examples
- name: Apply patch to one file ansible.posix.patch: src: /tmp/index.html.patch dest: /var/www/index.html - name: Apply patch to multiple files under basedir ansible.posix.patch: src: /tmp/customize.patch basedir: /var/www strip: 1 - name: Revert patch to one file ansible.posix.patch: src: /tmp/index.html.patch dest: /var/www/index.html state: absent
Collection links
© 2012–2018 Michael DeHaan
© 2018–2024 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/ansible/posix/patch_module.html