Is there a way to set a variable just for a task? Say the task uses the template module and I want to set a variable just for that task that is not specific to the host I’m on.
You should be able to put this variable in the rolename/defaults/main.yml file. This way there is a default value and if you do need to override it for a particular host or group you can do that easily.
You can define a variable (conditionally) inside the template, or use set_fact in the previous task, or include_vars in a previous task.
It depends on what you would like to achieve, and why.
I thought about using the set_fact in the previous task. It just seems more natural to set it in the same task, but that’s not possible.
Thanks,
Jim