Thanks. In that case, could I add a task to a play programmatically? I have around 20 plays and I try to have the vars section of each play to be saved locally to a yaml file. Right now, at the end of each play, I use a ‘copy’ tasks that reads the vars via a yaml alias. I would like to not repeat myself. I tried to place this task in a different play that is run after each one of the above plays , but ansible complains about an undefined alias. Do you see any way to not have to repeat the task in every play?
To save vars to a yaml file i would just use a template task, unsure
what you are doing or why, but this seems wrong to me.
On the import_tasks, include_tasks .. no clue what 'undefined alias'
is nor can i reproduce it, you need to give a full error with -vvv
(which will include traceback)