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)
---
- name: Test Template
hosts: app_host
vars:
nodeID1: node1
nodeID2: node2
tasks:
- name: Copying the properties file
template:
src: copy_appprops_node.j2
dest: "/appserver/instance/conf/app_properties.conf"
owner: app1
group: app1
mode: 0644
...
Any help and assistance would be highly appreciated.
Or, any idea that will work from the objective.
Thank you in advance.
Cheers....