patch – Apply patch files using the GNU patch tool
patch – Apply patch files using the GNU patch tool
New in version 1.9.
Synopsis
- Apply patch files using the GNU patch tool.
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
backup boolean added in 2.0 |
|
Passes |
basedir - |
Path of a base directory in which the patch file will be applied. May be omitted when | |
binary boolean added in 2.0 |
|
Setting to |
dest - |
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.
| |
remote_src boolean |
|
If |
src - / required |
Path of the patch file as accepted by the GNU patch tool. If
| |
state - added in 2.6 |
|
Whether the patch should be applied or reverted. |
strip - |
Default: 0 |
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. |
Notes
Note
- This module requires GNU patch utility to be installed on the remote host.
Examples
- name: Apply patch to one file
patch:
src: /tmp/index.html.patch
dest: /var/www/index.html
- name: Apply patch to multiple files under basedir
patch:
src: /tmp/customize.patch
basedir: /var/www
strip: 1
- name: Revert patch to one file
patch:
src: /tmp/index.html.patch
dest: /var/www/index.html
state: absent
Status
- This module is guaranteed to have no backward incompatible interface changes going forward. [stableinterface]
- This module is maintained by the Ansible Community. [community]
Authors
- Jakub Jirutka (@jirutka)
- Luis Alberto Perez Lazaro (@luisperlaz)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/patch_module.html