I define a variable “ansible_connection” under the task , but it still doesn’t work as it will always use winrm connectio that i have define in my job template
just be aware that in Ansible there is what we know as variable precedence. Check-out the docs for further info (there is an extensive precedence list, that’s most likely what you need to check from all the info on the docs):
In your case, since job templates extra vars have precedence over the playbook ones, then the former (extra vars) are overriding the latter (playbook vars).