I am working on a project that wants to provide ansible support for a solution that exposes a REST API. Over this API I designed an intermediate python layer to translate the yaml playbook into REST calls.
In my case, the playbook is composed of one task executed multiple times. During execution, I open a http connection to the actual target equipment using the python library requests, get an authentication token and send http calls. I noticed in the log files that although my fetch authentication token mechanism is a singleton class and all the tasks are executed against the same IP address, for each task the session is recreated and a new token is fetched.
Is there a way to reuse the http connection within the task list?
I have seen a similar post called: connection caching throughout a play but I hope there might be a workaround.
Alexandru Obretin <alexandru.obretin93@gmail.com> writes:
Hello,
I am working on a project that wants to provide ansible support for a
solution that exposes a REST API. Over this API I designed an intermediate
python layer to translate the yaml playbook into REST calls.
In my case, the playbook is composed of one task executed multiple times.
During execution, I open a http connection to the actual target equipment
using the python library requests, get an authentication token and send
http calls. I noticed in the log files that although my fetch
authentication token mechanism is a singleton class and all the tasks are
executed against the same IP address, for each task the session is
recreated and a new token is fetched.
Is there a way to reuse the http connection within the task list?
I have seen a similar post called: *connection caching throughout a play *but
I hope there might be a workaround.