I’m working on a play where I use the template module to put a shell script on the remote filesystem and then run that script. However, it’s inherently single-threaded because a) it’s a delegated task to a single database server for all hosts and b) the name of the file is the same - so it creates a race condition.
One option is for me to generate a random UUID and append the filename with that to force unique filenames (and thus allow me to run each script in parallel on the single remote endpoint), but I figured the job id might be a good option as well. However, as I was reading it looks like the job id is the same for all endpoints running the same task in a play - which means that’s not a good option. Additionally, I don’t see any documentation about how to get the job id back as part of the action (i.e. as a variable).
Any recommendations here for something more “clever” than just creating text to append to the filename using something like originating hostname + epoch or something like that?