# Custom Connection Plugin - to instatiate any generic "connection"

**URL:** <https://forum.ansible.com/t/custom-connection-plugin-to-instatiate-any-generic-connection/23004>\
**Category:** Ansible Developer\
**Created:** [November 10, 2016, 4:51pm UTC](https://forum.ansible.com/t/custom-connection-plugin-to-instatiate-any-generic-connection/23004 "2016-11-10T16:51:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayynadar](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@ayynadar](https://forum.ansible.com/u/ayynadar)\
**Post date:** [November 10, 2016, 4:51pm UTC](https://forum.ansible.com/t/custom-connection-plugin-to-instatiate-any-generic-connection/23004/1 "2016-11-10T16:51:35Z")

</div>

Hello - I spend a fair bit of time researching and the answer eludes me. Hoping that it is a simple mis-conception of mine that someone will correct.

I currently have a custom module to make REST API calls to a bunch of devices, it uses the “local” connection plugin. The custom module creates a connection everytime it needs to make a call. I was thinking maybe I could create a custom connection plugin - where I connect one time and then use that in the custom module. Besides the performance improvement - I am looking to simplify the playbook. Right not it has connection information in every single call. So if I need to change something it is a bit of a mess - yes I parameterized the values, but adding a new connection setting means changing every single task!

So I looked at the docker connector, the uri module to try and see how it is being done. For what I can gather, poring over the code, ConnectionBase class assumes that you want to do some variant of a ssh connection with copying files and executing on a remote server.

I am thinking of simply creating a dumb connector that does nothing but store the connections details I can use from my custom module. But then I cannot figure out how the module can query the connector being used for the necessary information.

Appreciate any help. Maybe my research was not sufficient - in which case please provide a link that I can read up or direct me to the source code that can help clarify my thinking.

Many thanks!

Ayya

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 10, 2016, 8:26pm UTC](https://forum.ansible.com/t/custom-connection-plugin-to-instatiate-any-generic-connection/23004/2 "2016-11-10T20:26:37Z")

</div>

Nothing exists yet, but I have this proposal [https://github.com/ansible/proposals/issues/24](https://github.com/ansible/proposals/issues/24) that would do ‘just that’

---

<div class="post-metadata">

**Author:** ![ayynadar](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@ayynadar](https://forum.ansible.com/u/ayynadar)\
**Post date:** [November 11, 2016, 3:27pm UTC](https://forum.ansible.com/t/custom-connection-plugin-to-instatiate-any-generic-connection/23004/3 "2016-11-11T15:27:59Z")

</div>

Thank you so much for replying! Glad I am not missing something significant. Really look forward to getting this kind of support - I mean your proposed auth\_plugins.

It will be really nice if you can also consider the following:

1. Avoid the overhead of invoking a connection\_plugins - albeit local in my case.
2. An alternative way to collect device “facts” as part of the authentication call.

I see this also useful for managing things like LDAP or RDBMS schema. One could do a LDAP connection and run various tasks regardless of the underlying OS hosting the LDAP server (or the LDAP vendor).

How does one support or vote for such a feature please?

Best,  
Ayya
