Hi,

You can try using the new (as of Ansible 2.4) "preview" telnet  module:
telnet - Executes a low-down and dirty telnet command
http://docs.ansible.com/ansible/2.4/telnet_module.html

Make sure your host file entries resolve in DNS or just use the IP.

Sample host file group:


[cisco]
arctic-sw01 host=10.1.10.100 port=22 username=cisco password=cisco
10.1.10.100 username=cisco password=cisco

Sample Playbook - here I am just getting the show inventory output (because 
its short) and saving it to a variable called output with is a data 
structure of all the output.  Then I take the part I want to save, the 
actual show inventory output and save it to a file called <hostname>.txt in 
the ./FACTs directory.
You can uncomment the term len 0 and show run commands and do the same.
---
- hosts: cisco 
  connection: local
  gather_facts: False
  ignore_errors: yes

  tasks:
    - name: run show commands via Telnet
      telnet:
        user: "{{ username }}"
        password: "{{ password }}"
        login_prompt: "Username: "
        prompts:
          - "[>|#]"
        command:
          # - terminal length 0
          # - show run
          - show inventory

      register: output

    - debug: var=output

    - local_action: copy content="{{ output.output[0] }}" dest="./FACTs/{{ 
inventory_hostname }}.txt"



Sample Run:
root@127c868b9dd3:/ansible/ansible2_4_base# ansible-playbook -i hosts 
ios_telnet.yml

PLAY [cisco] 
********************************************************************************************************************************

TASK [run show commands via Telnet] 
*********************************************************************************************************
changed: [arctic-sw01]
changed: [10.1.10.100]

TASK [debug] 
********************************************************************************************************************************
ok: [arctic-sw01] => {
    "output": {
        "changed": true,
        "failed": false,
        "output": [
            "show inventory\r\nNAME: \"arctic-sw01\", DESCR: \"Cisco 
Catalyst c2940 switch with 8 10/100 BaseTX ports and 1 10/100/1000 BaseT 
uplink port\"\r\nPID: WS-C2940-8TT-S    , VID: D0 , SN: 
FHK0834Y19X\r\n\r\n\r\narctic-sw01#"
        ]
    }
}
ok: [10.1.10.100] => {
    "output": {
        "changed": true,
        "failed": false,
        "output": [
            "show inventory\r\nNAME: \"arctic-sw01\", DESCR: \"Cisco 
Catalyst c2940 switch with 8 10/100 BaseTX ports and 1 10/100/1000 BaseT 
uplink port\"\r\nPID: WS-C2940-8TT-S    , VID: D0 , SN: 
FHK0834Y19X\r\n\r\n\r\narctic-sw01#"
        ]
    }
}

TASK [copy] 
*********************************************************************************************************************************
changed: [arctic-sw01 -> localhost]
changed: [10.1.10.100 -> localhost]

PLAY RECAP 
**********************************************************************************************************************************
10.1.10.100                : ok=3    changed=2    unreachable=0    failed=0
arctic-sw01                : ok=3    changed=2    unreachable=0    failed=0

root@127c868b9dd3:/ansible/ansible2_4_base# cd facts/
root@127c868b9dd3:/ansible/ansible2_4_base/facts# ls
10.1.10.100.txt  arctic-sw01.txt  nxos-spine1.txt  nxos-spine2.txt
root@127c868b9dd3:/ansible/ansible2_4_base/facts# cat 10.1.10.100.txt
show inventory
NAME: "arctic-sw01", DESCR: "Cisco Catalyst c2940 switch with 8 10/100 
BaseTX ports and 1 10/100/1000 BaseT uplink port"
PID: WS-C2940-8TT-S    , VID: D0 , SN: FHK0834Y19X


arctic-sw01#root@127c868b9dd3:/ansible/ansible2_4_base/facts


Hope this helps.

The only other approach I'm aware of is to use the NTC modules which use 
Napalm and the Cisco IOS modules use Netmiko under the hood which supports 
Telnet although last I checked I didn't think the Telnet option was 
exposed.  

Note that the end goal of this module is to telnet to a device to enable 
SSH but I know that is sometimes not possible. 






On Thursday, February 22, 2018 at 6:08:11 AM UTC-8, Daley Okuwa wrote:
>
> Is there any information that allows me to backup a cisco device using 
> telnet rather than ssh as the device do not support SSH
>
>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0061037a-2e95-4c35-8340-f27f2e459a66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to