# Jinja2 Template to use as SRC Path

**URL:** <https://forum.ansible.com/t/jinja2-template-to-use-as-src-path/33497>\
**Category:** Ansible Project\
**Created:** [July 26, 2020, 7:34pm UTC](https://forum.ansible.com/t/jinja2-template-to-use-as-src-path/33497 "2020-07-26T19:34:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Poseidon\_Olympian](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Poseidon\_Olympian](https://forum.ansible.com/u/Poseidon_Olympian)\
**Post date:** [July 26, 2020, 7:34pm UTC](https://forum.ansible.com/t/jinja2-template-to-use-as-src-path/33497/1 "2020-07-26T19:34:07Z")

</div>

Hello Group,

Requesting for advise or solution.  
The idea/objective is to have the specific filename to copy to the specific node as the SRC path.

**Filename**

node1-appprops.config  
node2-appprops.config

**Server Host**  
app\_server\_node1  
app\_server\_node2

**SRC Patch**

/ConfigurationFolder/WrapperConfig/temp

Someone says to use Jinja2 Template and I have created the file, copy\_appprops\_node.j2. And, the j2 contains like…

**J2 Template**  
_{% if ansible\_hostname is match(" app\*node1") %}_  
_/ConfigurationFolder/WrapperConfig/temp/{{nodeID1}}- appprops.config_  
_{% endif %}_

_{% if ansible\_hostname is match(" app\*node2") %}_  
_/ConfigurationFolder/WrapperConfig/temp/{{nodeID2}}- appprops.config_  
_{% endif %}_

**Playbook YML File (_running by different user_)**

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [July 27, 2020, 10:16pm UTC](https://forum.ansible.com/t/jinja2-template-to-use-as-src-path/33497/2 "2020-07-27T22:16:51Z")

</div>

I would try and organize variables so they are associated with the host in inventory, rather than setting a lot of playbook vars

`

# ansible inventory (notice both hosts in a group called ‘appservers’ )

[appservers]

app\_server\_node1 appprops\_file=node1-appprops.config  
app\_server\_node2 appprops\_file=node2-appprops.config  
`

**Playbook YML File (_running by different user_)**

`

---

<div class="post-metadata">

**Author:** ![Poseidon\_Olympian](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Poseidon\_Olympian](https://forum.ansible.com/u/Poseidon_Olympian)\
**Post date:** [July 30, 2020, 2:44am UTC](https://forum.ansible.com/t/jinja2-template-to-use-as-src-path/33497/3 "2020-07-30T02:44:52Z")

</div>

Hello Jon,

Thank you so much for the idea.

Cheers…
