HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Utilizing telnet with Ansible

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
telnetansiblewithutilizing

Problem

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?

Solution

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

Code Snippets

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

  tasks:
    - name: my first telnet task
      telnet:
        username: user
        password: pass
        command:
          - my command

Context

StackExchange DevOps Q#3454, answer score: 6

Revisions (0)

No revisions yet.