# telnet issue

**URL:** <https://forum.ansible.com/t/telnet-issue/32668>\
**Category:** Ansible Project\
**Created:** [April 13, 2020, 7:07am UTC](https://forum.ansible.com/t/telnet-issue/32668 "2020-04-13T07:07:25Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 13, 2020, 7:07am UTC](https://forum.ansible.com/t/telnet-issue/32668/1 "2020-04-13T07:07:25Z")

</div>

Hi Experts,

I am just new with this one. I am trying to connect using telnet (ssh has no issue) to my IOS devices, but I am getting error when I run my playbook:

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 13, 2020, 7:09am UTC](https://forum.ansible.com/t/telnet-issue/32668/2 "2020-04-13T07:09:58Z")

</div>

I am getting this when I do -vvv

ansible-playbook 2.8.5  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible-playbook  
python version = 2.7.5 (default, Aug 7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]  
Using /etc/ansible/ansible.cfg as config file  
host\_list declined parsing /etc/ansible/TEMPLATES/Cisco\_IOS as it did not pass it’s verify\_file() method  
Skipping due to inventory source not existing or not being readable by the current user  
script declined parsing /etc/ansible/TEMPLATES/Cisco\_IOS as it did not pass it’s verify\_file() method  
auto declined parsing /etc/ansible/TEMPLATES/Cisco\_IOS as it did not pass it’s verify\_file() method  
Skipping due to inventory source not existing or not being readable by the current user  
yaml declined parsing /etc/ansible/TEMPLATES/Cisco\_IOS as it did not pass it’s verify\_file() method  
Skipping due to inventory source not existing or not being readable by the current user  
ini declined parsing /etc/ansible/TEMPLATES/Cisco\_IOS as it did not pass it’s verify\_file() method  
Skipping due to inventory source not existing or not being readable by the current user  
toml declined parsing /etc/ansible/TEMPLATES/Cisco\_IOS as it did not pass it’s verify\_file() method  
[WARNING]: Unable to parse /etc/ansible/TEMPLATES/Cisco\_IOS as an inventory source  
[WARNING]: No inventory was parsed, only implicit localhost is available  
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [April 13, 2020, 7:23am UTC](https://forum.ansible.com/t/telnet-issue/32668/3 "2020-04-13T07:23:10Z")

</div>

Can you connect to your IOS devices normally, i.e. outside Ansible?

If yes, then I have no idea what’s going on, but if not, get that working first before you try doing it with Ansible.

Off the cuff theory is that the devices do not permit telnet connections…

Regards, K.

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 13, 2020, 7:51am UTC](https://forum.ansible.com/t/telnet-issue/32668/4 "2020-04-13T07:51:28Z")

</div>

Hi Karl,

yes, I can connect to the device from my ansible server using telnet. I can also connect to the device using my putty (outside of ansible) using telnet.

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 13, 2020, 7:58am UTC](https://forum.ansible.com/t/telnet-issue/32668/5 "2020-04-13T07:58:39Z")

</div>

I am getting this error:

FAILED! =\> {“changed”: true, “msg”: “Telnet action failed: telnet connection closed”, “output”: }

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [April 13, 2020, 8:05am UTC](https://forum.ansible.com/t/telnet-issue/32668/6 "2020-04-13T08:05:26Z")

</div>

Unless you have some specific reason for wanting to use telnet, the obvious workaround is to use ssh instead…

Regards, K.

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 13, 2020, 8:14am UTC](https://forum.ansible.com/t/telnet-issue/32668/7 "2020-04-13T08:14:38Z")

</div>

Hi Karl,

Unfortunately, those devices that we have are old and uses telnet 🙂

But other devices which are SSH enabled are being automated by ansible

---

<div class="post-metadata">

**Author:** ![Srinivas\_Naram](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Srinivas\_Naram](https://forum.ansible.com/u/Srinivas_Naram)\
**Post date:** [April 13, 2020, 8:26am UTC](https://forum.ansible.com/t/telnet-issue/32668/8 "2020-04-13T08:26:51Z")

</div>

Some time back just to test telnet module, I tried telnet for devices which had ssh as well as telnet access. However I was not successful and gave up. If you get this working, kindly reply with the solution.

Thanks  
Srinivas.

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 13, 2020, 8:37am UTC](https://forum.ansible.com/t/telnet-issue/32668/9 "2020-04-13T08:37:13Z")

</div>

Hi Srinivas,

Sure! I will update you.

This is just weird, I tried it on GNS3 and it is working. but on the prod itself, it is not.

playbook is just straight forward:

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 13, 2020, 2:28pm UTC](https://forum.ansible.com/t/telnet-issue/32668/10 "2020-04-13T14:28:59Z")

</div>

Gettign this logs:

host\_list declined parsing /etc/ansible/TEMPLATES/Cisco\_Telnet as it did not pass it’s verify\_file() method  
Skipping due to inventory source not existing or not being readable by the current user

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 16, 2020, 6:32am UTC](https://forum.ansible.com/t/telnet-issue/32668/11 "2020-04-16T06:32:23Z")

</div>

This looks like a playbook just copied from documentation.  
[https://docs.ansible.com/ansible/latest/modules/telnet\_module.html](https://docs.ansible.com/ansible/latest/modules/telnet_module.html)

Your task is missing host: default is the variable remote\_addr according to the  
documentation. So you need to provide host: or sett the correct variable.

You also need to tailor the prompt for you environment, it should be a list of  
all prompt, you only have one prompt that is literally checking for [\>|#] I  
doubt you prompt looks like that.

If you can't figure this out yourself you need to provide the complete output  
of telnet including telnet itself and the exit of the telnet.

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 16, 2020, 2:37pm UTC](https://forum.ansible.com/t/telnet-issue/32668/12 "2020-04-16T14:37:08Z")

</div>

Hi Kai,

Thank you very much for replaying on my issue. I know that it should be straight forward, and I just copy it on the module

I am still getting the failure message even though I changed the hosts to

[Cisco\_Telnet]  
10.197.48.240

Tasks:

- name: Telnet do show version for IOS  
hosts: 10.197.48.240  
gather\_facts: false  
connection: local

tasks:

- name: show version  
telnet:  
user: ansible  
password: Inf1n1TY  
login\_prompt: “Username:”  
prompts:
- “[#]”  
command:
- terminal length 0
- show version

Here is the error:

PLAY [Telnet do show version for IOS] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*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\*  
fatal: [10.197.48.240]: FAILED! =\> {“changed”: true, “msg”: “Telnet action failed: telnet connection closed”, “output”: }

Here is when i do the -vvv:

Using /etc/ansible/ansible.cfg as config file  
host\_list declined parsing /etc/ansible/TEMPLATES/Cisco\_IOS as it did not pass it’s verify\_file() method  
Skipping due to inventory source not existing or not being readable by the current user  
script declined parsing /etc/ansible/TEMPLATES/Cisco\_IOS as it did not pass it’s verify\_file() method

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 21, 2020, 5:04am UTC](https://forum.ansible.com/t/telnet-issue/32668/13 "2020-04-21T05:04:24Z")

</div>

for telnet use 5 v's (-vvvvv) , 3 won't show anything about the task.

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 23, 2020, 3:45am UTC](https://forum.ansible.com/t/telnet-issue/32668/14 "2020-04-23T03:45:30Z")

</div>

HI Brian,

Thank you for the reply.

I did the 5v’s as you mentioned, and dont know why it is saying that the hosts does not match.

TEMPLATES]# cp IOS\_telnet.yaml /etc/ansible/  
[root@spm6637 TEMPLATES]# ansible-playbook -i Cisco\_Telnet IOS\_telnet.yaml  
[WARNING]: Unable to parse /etc/ansible/TEMPLATES/Cisco\_Telnet as an inventory source  
[WARNING]: No inventory was parsed, only implicit localhost is available  
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’  
[WARNING]: Could not match supplied host pattern, ignoring: Cisco\_Telnet

PLAY [Telnet do show version for IOS] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: no hosts matched

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

I tried pinging it, and it was successful.

TEMPLATES]# ansible Cisco\_Telnet -m ping  
d2c2e-be-ag249-o | SUCCESS =\> {  
“changed”: false,  
“ping”: “pong”

TEMPLATES]# ansible --list-host Cisco\_Telnet  
hosts (1):  
d2c2e-be-ag249-o

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 23, 2020, 3:50am UTC](https://forum.ansible.com/t/telnet-issue/32668/15 "2020-04-23T03:50:48Z")

</div>

I can also see my inventory:

TEMPLATES]# ansible all --list-hosts  
hosts (1):  
d2c2e-be-ag249-o

---

<div class="post-metadata">

**Author:** ![Zaldy\_B](https://avatars.discourse-cdn.com/v4/letter/z/ec9cab/32.png) [@Zaldy\_B](https://forum.ansible.com/u/Zaldy_B)\
**Post date:** [April 23, 2020, 3:52am UTC](https://forum.ansible.com/t/telnet-issue/32668/16 "2020-04-23T03:52:24Z")

</div>

Here is my cfg file:

ansible]# cat ansible.cfg  
[defaults]

# Use local hosts file

inventory = /etc/ansible/hosts

# Disable SSH key host checking (RSA fingerprints)

host\_key\_checking = False

# Do not create .retry files on job failures

retry\_files\_enabled = False

# Do not gather facts

gathering = explicit

#python Interpreter for Ansible 2.8 onwards  
interpreter\_python = /usr/bin/python3

---

<div class="post-metadata">

**Author:** ![Werner\_Flamme](https://avatars.discourse-cdn.com/v4/letter/w/c68b51/32.png) [@Werner\_Flamme](https://forum.ansible.com/u/Werner_Flamme)\
**Post date:** [April 23, 2020, 5:05am UTC](https://forum.ansible.com/t/telnet-issue/32668/17 "2020-04-23T05:05:55Z")

</div>

> HI Brian,
> 
> Thank you for the reply.
> 
> I did the 5v's as you mentioned, and dont know why it is saying that the  
> hosts does not match.
> 
> TEMPLATES]# cp IOS\_telnet.yaml /etc/ansible/  
> [root@spm6637 TEMPLATES]# ansible-playbook -i Cisco\_Telnet IOS\_telnet.yaml

Zaldy,

-i is not to be followed by a hostname the playbook will be excuted on,  
but by an inventory list (either a file name or a host list). You have  
to specify the hosts file here, at least that is what the first WARNING  
is about

> [WARNING]: Unable to parse /etc/ansible/TEMPLATES/Cisco\_Telnet as an  
> inventory source

The rest is a follow-up error: since the mentioned inventory list has  
not been found, there is no 'all' host group and no host other than  
'localhost' at all.

> [WARNING]: No inventory was parsed, only implicit localhost is available  
> [WARNING]: provided hosts list is empty, only localhost is available. Note  
> that the implicit localhost does not match 'all'  
> [WARNING]: Could not match supplied host pattern, ignoring: Cisco\_Telnet

My proposal: you should skip the "-i Cisco\_Telnet" part of the  
commandline and instead put the hostname inside the playbook.
