W3cubDocs

/Ansible

patch - Apply patch files using the GNU patch tool.

New in version 1.9.

Synopsis

  • Apply patch files using the GNU patch tool.

Options

parameter required default choices comments
backup
(added in 2.0)
no no
  • yes
  • no
passes --backup --version-control=numbered to patch, producing numbered backup copies
basedir
no
Path of a base directory in which the patch file will be applied. May be omitted when dest option is specified, otherwise required.
binary
(added in 2.0)
no no
Setting to yes will disable patch's heuristic for transforming CRLF line endings into LF. Line endings of src and dest must match. If set to no, patch will replace CRLF in src files on POSIX.
dest
no
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.
aliases: originalfile
remote_src
no no
  • yes
  • no
If no, it will search for src at originating/master machine, if yes it will go to the remote/target machine for the src. Default is no.
src
yes
Path of the patch file as accepted by the GNU patch tool. If remote_src is 'no', the patch source file is looked up from the module's "files" directory.
aliases: patchfile
strip
no 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.

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

Notes

Note

  • This module requires GNU patch utility to be installed on the remote host.

Status

This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.

Support

This module is community maintained without core committer oversight.

For more information on what this means please read Module Support

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/patch_module.html