connection caching throughout a play

HI!

On the ansible controller I'd like to establish an authenticated LDAP
connection at the beginning of a playbook run and use this afterwards in
several tasks.

Up to now the ansible modules I reviewed seem to re-open all kinds of
backend connections all the time using long-term credentials. Which
means I cannot use 2-factor-auth with an OTP.
(No, using Kerberos is not an option.)

So I wonder whether it's possible to cache a connection object and
re-use it in subsequent tasks. Any framework for something like this?

Ciao, Michael.

Currently there is no way to do this, but it is something we have been
thinking about for a while now as a feature.

Just don't expect it anytime soon, as it is a complex ask, specially
if you consider modules are not guaranteed to execute on the same
machine.