telnet module?

1,741 views
Skip to first unread message

Bas Meijer

unread,
Apr 15, 2014, 5:33:40 PM4/15/14
to ansible...@googlegroups.com
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.

Michael DeHaan

unread,
Apr 15, 2014, 5:49:37 PM4/15/14
to ansible...@googlegroups.com
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





On Tue, Apr 15, 2014 at 5:33 PM, Bas Meijer <bas.m...@iwelcome.com> wrote:
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/91124DEF-F2F0-40D1-94B1-A673D7119008%40iwelcome.com.
For more options, visit https://groups.google.com/d/optout.

Bas Meijer

unread,
Apr 16, 2014, 2:54:33 AM4/16/14
to ansible...@googlegroups.com
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 '^]'.
osgi> 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.



Michael DeHaan

unread,
Apr 16, 2014, 7:42:48 AM4/16/14
to ansible...@googlegroups.com
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 :)




Bas Meijer

unread,
Apr 16, 2014, 9:05:54 AM4/16/14
to ansible...@googlegroups.com
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. 

<IMHO> 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.

Michael DeHaan

unread,
Apr 16, 2014, 9:49:37 AM4/16/14
to ansible...@googlegroups.com
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.


Adam Morris

unread,
Apr 16, 2014, 2:01:10 PM4/16/14
to ansible...@googlegroups.com


On Wednesday, April 16, 2014 6:49:37 AM UTC-7, Michael DeHaan wrote:

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

Damien Michaudet

unread,
Aug 5, 2015, 9:27:58 AM8/5/15
to Ansible Project
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 :)

++

Brian Coca

unread,
Aug 5, 2015, 9:47:30 AM8/5/15
to Ansible Project
a telnet connection plugin might be what you are looking for.



--
Brian Coca

Paul Markham

unread,
Aug 5, 2015, 11:47:33 PM8/5/15
to Ansible Project
The expect module in Ansible 2.0 might do what you want.
Reply all
Reply to author
Forward
0 new messages