Is there by any chance a ‘telnet’ module? I would like to connect to a certain port on localhost and enter text and look for strings in the output.
There isn’t, and quite intentionally.
Telnet is a obviously a very insecure protocol, completely insecure in fact, and we strongly want to discourage usage.
Yet, it would be quite trivial to write a connection plugin to support it, though, as connection plugins just need to support the ability to put a file, get a file, and execute a module (assume ftp would also be used rather than netcat?).
To be honest, I considered it as an April fools joke at one point – to actually implement it – but I didn’t do it.
Most networking equipment – though a lot of the ways people attempt to configure networking equipment with Ansible can be hacky – can usually be coerced into enabling SSH.
We would likely refuse the pull request, to be honest – it is just asking for a world of hurt should MITM possibilities arise.
–Michael
Obviously I am not running a telnet server, hence the quotes in my question. Tomcat Virgo is an OSGi Java server that allows management with a localhost telnet-like interface for managing OSGi modules. Allowing a query ‘ss’ and commands like ‘refresh 140’, ‘stop 123’, ‘start 54’.
$ telnet localhost 2501
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
ss
“Framework is launched.”
id State Bundle
0 ACTIVE org.eclipse.osgi_3.8.1.v20120830-144521
Fragments=1
35 ACTIVE org.eclipse.virgo.kernel.userregionfactory_3.6.2.RELEASE
64 ACTIVE org.eclipse.equinox.cm_1.0.400.v20120319-2029
65 ACTIVE org.eclipse.virgo.kernel.userregion_3.6.2.RELEASE
66 ACTIVE org.eclipse.virgo.shell.command_3.6.2.RELEASE
67 ACTIVE org.eclipse.osgi.services_3.3.0.v20120307-2102
…
Lot’s of other protocols print a header with their version on connect, have a debug port, or allow a shutdown string. A generic ‘telnet’ module would be a nice addition to the ansible toolbox. If it is as simple as you said, just do it please.
So in that case, what I would probably do is write a module for managing the OSGI modules, and this module could be deployed via the regular SSH mechanism and then could connect to 127.0.0.1:port to send commands from that module.
We have some other modules that speak “API” once deployed, many rely on various libraries versus low-level socket bits, for which you may have some in Python available to you, if not, telnet protocol isn’t too atrocious
This one ‘telnet’ module could be used in many cases. Abstracting by implementing this in a generic way, like uri, get_url, wait_for, would add more power to the core modules.
Implementing adapter modules for each and every API looks like a maintenance burden. When I first looked at the list of api modules, it looked haphazard.
I don’t understand your comment about the “api” modules, as there really aren’t any API modules.
There are modules for specific services, which have an API.
It wouldn’t make since to combine OpenStack and Twilio and F5 all in common code, because they are used differently and most do have bindings which the libraries use.
Anyway, telnet – while a module to send commands to telnet could be generic, most likely you’ll care to parse the responses, and quickly need some “expect” like magic to perform a particular function.
Thus what you are discussing should really be (IMHO) a OSGI module or whatever, rather than a telnet module – why? It leads to infinitely clear playbooks, describing desired resource state, not commands sent.
While I agree that a telnet module is a bad idea (for a large number of reasons) and wouldn’t want to see Telnet as a connection protocol either. Python already has some such libraries so that this adding a utility library within Ansible is really a moot point. In this case the documentation for telnetlib makes it looks like using it to write a module for Tomcat Virgo would be relatively straightforward.
Adam
Hi all,
i have to manage several WiFi devices that can be controlled by a web interface or telnet commands.
While i’m thinking about Behat to script configuration routines via the web interface, i’d be much more comfortable using ansible, with a telnet module.
We know it’s insecure, that’s what makes it so interesting, and it forces us to think different about what we share on the network.
Being able to push all the configurations to the wifi repeater, which connect to a Radius server for authentication, would be really nice.
And thank you for the work done on Ansible
a telnet connection plugin might be what you are looking for.
The expect module in Ansible 2.0 might do what you want.