# Is it possible to use templates as a source when using the patch module?

**URL:** <https://forum.ansible.com/t/is-it-possible-to-use-templates-as-a-source-when-using-the-patch-module/23556>\
**Category:** Ansible Project\
**Created:** [January 25, 2017, 11:00am UTC](https://forum.ansible.com/t/is-it-possible-to-use-templates-as-a-source-when-using-the-patch-module/23556 "2017-01-25T11:00:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrstphrptrs](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@chrstphrptrs](https://forum.ansible.com/u/chrstphrptrs)\
**Post date:** [January 25, 2017, 11:00am UTC](https://forum.ansible.com/t/is-it-possible-to-use-templates-as-a-source-when-using-the-patch-module/23556/1 "2017-01-25T11:00:05Z")

</div>

Hi,

I’m wondering whether it’s possible to use a Jinja2 template as a source in a patch task.  
(Documentation of the module: [http://docs.ansible.com/ansible/patch\_module.html](http://docs.ansible.com/ansible/patch_module.html))

An example:

- name: Copy patch template to remote system  
template:  
src: mypatch.patch.j2  
dest: /tmp/mypatch.patch

- name: Apply patch  
patch:  
src: /tmp/mypatch.patch  
dest: /some/destination/to/patch  
remote\_src: yes

I would like to replace this with:

- name: Apply patch  
patch:  
src: mypatch.patch.j2  
dest: /some/destination/to/patch

Is this possible? If yes, what is right way to do this?  
Is there someone who can help me?

Thank you!

Best regards,

Christopher

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 25, 2017, 5:15pm UTC](https://forum.ansible.com/t/is-it-possible-to-use-templates-as-a-source-when-using-the-patch-module/23556/2 "2017-01-25T17:15:59Z")

</div>

No, but you can use the template module to generate the patch file before running the patch module.
