How to reuse an http client object ?

Hello Community,

Is it possible to put a client object somewhere so it can be shared/reused by custom plugins ? That is, only for tasks running on the controlling node.

I’m trying to reuse the very same pysnow client object in successive tasks. Hoping to improve the performance of a very long running playbook.

THX

I'm assuming you are in a collection context, so plugins/module_utils
(they are also available to controller, not just modules)

No collections. Just the classic *_plugins directories. For example action_plugins.

The code is available to the controlling node too. What I’m trying to achieve is to create once the pysnow client, put it ‘somewhere’ and have the action plugins access this very same object. However, what is that ‘somewhere’, if any.

Unfortunately, every task runs in a different process (the pid is different) but they all share the same parent process. So, maybe, there is a way. I guess this is what Ansible does when it reuses the ssh connection.

Just don’t know where to look :slight_smile:

Hi,

Is it possible to put a client object somewhere so it can be
shared/reused by custom plugins ? That is, only for tasks running on
the controlling node.

I'm trying to reuse the very same pysnow client object in successive
tasks. Hoping to improve the performance of a very long running
playbook.

for modules there exists some framework in cloud.common
(https://galaxy.ansible.com/cloud/common) called 'Ansible turbo module'
providing something like that (disclaimer: I've never used it). Not
sure whether that also works for plugins though...

Cheers,
Felix

I don’t know it either, but I’ll have a look. thanks for the hint ! :slight_smile:

So, if I’m getting this right, the idea is that the custom plugin code connects with a daemon process. And that daemon maintains the connection and other stateful data ?