5

Was wondering how to best utilize telnet, rather than SSH, with ansible. We are using a Lantronix term server, and must telnet into individual ports.

More specifically, would it be best to use a specific telnet module? If so, which is most intuitive. Alternatively, is it more efficient to simply modify connection type within the hosts file / YAML playbook?

030
  • 13,235
  • 16
  • 74
  • 173
Andrew H
  • 53
  • 1
  • 1
  • 3

2 Answers2

6

As documented here, ansible does not support telnet as connection plugin. This means you cannot use ansible to connect to a remote machine via telnet and execute any of the ansible modules.

However, you can use connection: local for local connection(run ansible against the machine that is running it) and send telnet commands from the machine where ansible runs.

Example playbook will look something like that:

---
- hosts: localhost
  connection: local
  gather_facts: false

  tasks:
    - name: my first telnet task
      telnet:
        username: user
        password: pass
        command:
          - my command
kenorb
  • 7,841
  • 12
  • 40
  • 77
man0v
  • 251
  • 1
  • 6
  • Where are you specifying the remote device that you are telneting to? It looks like you are just telneting the localhost. – Frak Oct 15 '20 at 23:34
  • nowhere; If you read carefuly I say "Example playbook will look something like that:"; Nowhere I even try to suggest a remote connection. I don't understand your question? – man0v Oct 17 '20 at 16:51
2

Ansible provides a module for telnet provisioning. See:

https://docs.ansible.com/ansible/latest/modules/telnet_module.html

mcandre
  • 119
  • 3