# Patch module

**URL:** <https://forum.ansible.com/t/patch-module/12624>\
**Category:** Ansible Project\
**Created:** [April 4, 2013, 2:33am UTC](https://forum.ansible.com/t/patch-module/12624 "2013-04-04T02:33:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [April 4, 2013, 2:33am UTC](https://forum.ansible.com/t/patch-module/12624/1 "2013-04-04T02:33:27Z")

</div>

I’d like to write a “patch” module that copies over a patch file and runs (idempotenetly) runs the patch program.

How do I copy a local file to the remote machine inside an ansible module?

Lorin

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 4, 2013, 12:35pm UTC](https://forum.ansible.com/t/patch-module/12624/2 "2013-04-04T12:35:14Z")

</div>

You would have to do something like the 'copy' module where there is  
both a local and remote plugin component.

As this mostly just needs the functionality of the copy plugin, it  
might be nice to just find a way to put some metadata in the module  
itself that lets it transfer src to dest via  
copy before running (i.e. some modification to runner.py).

If that is done, a good way to test would be to implement copy.py  
(modify it) to allow the remote module to work exactly like this.

Until then, you would just need the two stage process and require the  
path module to take a local path.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 4, 2013, 12:35pm UTC](https://forum.ansible.com/t/patch-module/12624/3 "2013-04-04T12:35:21Z")

</div>

s/path/patch/

---

<div class="post-metadata">

**Author:** ![Yang\_Zhang](https://avatars.discourse-cdn.com/v4/letter/y/96bed5/32.png) [@Yang\_Zhang](https://forum.ansible.com/u/Yang_Zhang)\
**Post date:** [April 12, 2013, 8:53pm UTC](https://forum.ansible.com/t/patch-module/12624/4 "2013-04-12T20:53:08Z")

</div>

Hi Lorin, did you ever write a patch module or modify the file module  
as suggested by Michael? I for one would find this useful.

---

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [April 12, 2013, 8:55pm UTC](https://forum.ansible.com/t/patch-module/12624/5 "2013-04-12T20:55:19Z")

</div>

Hi Yang:

No, I’m afraid not, unfortunately other stuff has been keeping me busy. Not sure when I’ll have a chance at this.

Take care,

Lorin

---

<div class="post-metadata">

**Author:** ![Luis\_Perez](https://avatars.discourse-cdn.com/v4/letter/l/aca169/32.png) [@Luis\_Perez](https://forum.ansible.com/u/Luis_Perez)\
**Post date:** [July 24, 2013, 9:08am UTC](https://forum.ansible.com/t/patch-module/12624/6 "2013-07-24T09:08:01Z")

</div>

Hello,

Some months ago i wrote a small patch module. However it assumes that the patch file is already uploaded to the remote machine. I didn’t have the time to improve it. You can find it here:

[https://github.com/luisperlaz/ansible-misc-modules/blob/master/patch](https://github.com/luisperlaz/ansible-misc-modules/blob/master/patch)

Luis

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [July 24, 2013, 3:26pm UTC](https://forum.ansible.com/t/patch-module/12624/7 "2013-07-24T15:26:10Z")

</div>

nice, this is/was on my list, mind if i expand it to be able to copy the file from ‘master’ ?
