Terminal connection plugin: access to host or play inventory details?

Hi,

I’m currently trying to create a terminal connection plugin. The goal is to connect to a console port via a terminal server. So the plugin must be able to deal with the initial terminal connection and have to authenticate against the device.
I have have current sample working overall, but I’m stuck on how I can handle the credentials?

The inventory data for ansible)user and password are used for the ssh session to the terminal server itself, so I need a 2nd pair of credentials which I can ideally define in the inventory. How can I either pass this 2nd set of credentials to the plugin or how can the plugin look this info up?

I was hoping that the “_connection._play_context” would help, but I am unsure how to add information to it?

Any help or hint would be greatly appreciated.

Regards
Rene

Checkout this example here from the ibm.isam collection: https://github.com/IBM-Security/isam-ansible-collection/blob/master/plugins/connection/isam.py#L37

That docstring is important because ansible-core will parse that docstring and populate variables based on the docstring as effectively an arg spec for the connection plugin. It’s admittedly a bit obtuse and I don’t think it’s well documented, if at all, but I ended up finding that in the code at some point and recommended that method to the ibm.isam developers who were asking about it in the past.

Hope that helps!

The documentation for plugin options is located at Developing plugins — Ansible Documentation

While there’s room for improvement, I don’t think it’s particularly poorly documented (compared to, say, how to use the standard module utilities :slight_smile:)