'How to use the libssh connection plugin on ansible

I'm working on a playbook to create/delete users on different storage devices.
The problem is that ansible is not able to create the temp directory and execute the module code.

I was thinking to use shell to create the connection and then to run the command.
Something like this:

- name: Create user
    shell: |
         sshpass "password" ssh user@storage_device
         command_to_create_user
         exit

Obviously this approach is risky, if you are not able to connect to the server, you can run the command on the local ansible server.

I have been told that network plugins exist to create a similar connection (ansible.netcommon.network_cli). But I wasn't able to find much information. https://www.ansible.com/blog/new-libssh-connection-plugin-for-ansible-network

How can use the libssh connection plugin to run a command?

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source