How to use enable password with ansible

I am trying to perform telnet which works fine with username & password but i want to find a way to enter enable password. Below example does not work.

  • name: run show commands
    hosts: routers
    gather_facts: False
    tasks:

  • telnet:
    password: cisco
    prompts:

  • “[>|#]”
    command:

  • enable

  • “password”

  • show version

I was able to make it work but now after successful execution, it does not make changes on the end device but result says changes are done.

root@NetworkAutomation-2:~# cat telnettest.yml

Ansible offers dedicated functionality to deal with enable mode on IOS:

https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html

Thank you for the response but i am working on TELNET not SSH.

I am able to telnet the router but changes are not taking effect.

can any expert guide here?

Hi,
Because I have no cisco device on handy, I “guess” this may work!
Add “Password:” (after “enable” command) as a valid prompt.

prompts:

  • “[>|#] |Password:”

Reference page:https://qiita.com/Yohichi_Hayashi/items/772ea6b1e66d4cc8aa26`

sincerely,
Jane#

Ankur Atri於 2019年7月5日星期五 UTC+8下午12時37分34秒寫道:

Hi Ankur,

I had the same problem with some old hardware, and found, after studying the code 1, that the following solution works:

  • name: run show commands
    hosts: routers
    gather_facts: false

connection: local

tasks:

  • telnet:
    login_prompt: "Password: "
    user: “{{ password }}”

prompts:

  • “[>#]”
    command:

  • “enable\n{{ enable_password }}”

  • terminal length 0

  • show running-config

Cheers,

Chris Chapman