In ansible we are trying to access different templates based on variable.
We have following template files like:
templates
app1.conf.j2
app2.conf.j2
app3.conf.j2
taks
app.yml
In tasks we need to copy template file based on the app name. for eg: we
will specify a variable named "instance_name" to either app1 or app2 or
app3.
Now based on the variable we need to copy the app file to /opt/((
instance_name }}/conf.d/.
we created ansbile task as follows but its not working.
- name: 'Copy {{ instance_name }} file to /opt/conf.d/ Directory'
template:
src: "{{ instance_name }}"
dest: "/opt/{{ instance_name }}/conf.d/"
owner: root
group: root
mode: 0644
When we hard code "src" to app1.conf.j2 its working for app1.
Please let us know is it possible with this method? We are having around 20
apps and whats the best method to simplify the ansible playbook to specify
only the variable.
Thanks & Regards
Geo
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAKtc8vWncufK%3DvO%3DEpRCUr_MavBAzT_wSWURXybW7b3r-BO_UA%40mail.gmail.com.