�
�Udac @` s d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d d
l Z d d l
m Z d d l m
Z
m Z d d
l m Z d e f d � � YZ d � Z d
e d d d � Z d
e d e e d d � Z d � Z e d k r� e � n d
S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont stableinterfacet statust communityt supported_bys�
---
module: patch
author:
- Jakub Jirutka (@jirutka)
- Luis Alberto Perez Lazaro (@luisperlaz)
version_added: '1.9'
description:
- Apply patch files using the GNU patch tool.
short_description: Apply patch files using the GNU patch tool
options:
basedir:
description:
- Path of a base directory in which the patch file will be applied.
- May be omitted when C(dest) option is specified, otherwise required.
type: path
dest:
description:
- 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.
type: path
aliases: [ originalfile ]
src:
description:
- Path of the patch file as accepted by the GNU patch tool. If
C(remote_src) is 'no', the patch source file is looked up from the
module's I(files) directory.
type: path
required: true
aliases: [ patchfile ]
state:
description:
- Whether the patch should be applied or reverted.
type: str
choices: [ absent, present ]
default: present
version_added: "2.6"
remote_src:
description:
- If C(no), it will search for src at originating/master machine, if C(yes) it will
go to the remote/target machine for the C(src).
type: bool
default: no
strip:
description:
- 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.
type: int
default: 0
backup:
version_added: "2.0"
description:
- Passes C(--backup --version-control=numbered) to patch, producing numbered backup copies.
type: bool
default: no
binary:
version_added: "2.0"
description:
- Setting to C(yes) will disable patch's heuristic for transforming CRLF
line endings into LF.
- Line endings of src and dest must match.
- If set to C(no), C(patch) will replace CRLF in C(src) files on POSIX.
type: bool
default: no
notes:
- This module requires GNU I(patch) utility to be installed on the remote host.
s`
- 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
N( t
format_exc( t
AnsibleModulet get_platform( t to_nativet
PatchErrorc B` s e Z RS( ( t __name__t
__module__( ( ( s? /usr/lib/python2.7/site-packages/ansible/modules/files/patch.pyR p s c C` s6 t � j � d k r% | j d � n
| j d � d S( Nt openbsdt netbsdt freebsds --checks --dry-run( R R R ( R
t lowert append( t opts( ( s? /usr/lib/python2.7/site-packages/ansible/modules/files/patch.pyt add_dry_run_optiont s t presentc
C` s� d d d | d | d | g } t | � | rA | j d � n | r[ | j d | � n | d k rw | j d � n | | � \ } } } | d
k S( Ns --quiets --forwards
--strip=%ss --directory='%s's --input='%s's --binarys '%s'R s --reversei ( R R (
t
patch_funct
patch_filet basedirt dest_filet binaryt stript stateR t rct _( ( s? /usr/lib/python2.7/site-packages/ansible/modules/files/patch.pyt is_already_applied| s
c C` s� d d d d d | d | d | g } | r: t | � n | rP | j d � n | rj | j d | � n | r� | j d
� n | d k r� | j d � n | | � \ }
} } |
d
k r� | p� | }
t |
� � n d S( Ns --quiets --forwards --batchs --reject-file=-s
--strip=%ss --directory='%s's --input='%s's --binarys '%s's# --backup --version-control=numberedt absents --reversei ( R R R ( R R R R R R t dry_runt backupR R R t outt errt msg( ( s? /usr/lib/python2.7/site-packages/ansible/modules/files/patch.pyt apply_patch� s"