Jinja2 Template to use as SRC Path

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)

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)

`

Hello Jon,

Thank you so much for the idea.

Cheers…