Defined two variables:
vars:
var1: a
var2: b
Use these two variables in a template file:
{{ var1 }} string
{{ var2 }} string
Set template file to servers(two servers):
- name: Update file
template:
src: file.j2
dest: /etc/somefile
Then check the /etc/somefile
on the servers, got this content:
$ cat /etc/somefile
b string
b string
But not:
$ cat /etc/somefile
a string
b string
Why?
Step by step you'll have to find out where do the values of the variables come from. Start with the debug task
See Variable precedence: Where should I put a variable?. The playbook vars precedence is 12. and can be overridden by 13-22.