Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document prompt ability for network/*_command modules #39201

Closed
IPvSean opened this issue Apr 23, 2018 · 19 comments · Fixed by #66584
Closed

Document prompt ability for network/*_command modules #39201

IPvSean opened this issue Apr 23, 2018 · 19 comments · Fixed by #66584
Assignees
Labels
affects_2.6 This issue/PR affects Ansible v2.6 cisco Cisco technologies docs This issue/PR relates to or includes documentation. ios Cisco IOS community iosxr Cisco IOSXR community module This issue/PR relates to a module. networking Network category nxos Cisco NXOS community support:network This issue/PR relates to code supported by the Ansible Network Team.

Comments

@IPvSean
Copy link
Contributor

IPvSean commented Apr 23, 2018

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

ios_command
vyos_command
nxos_command
iosxr_command
junos_command
eos_command

ANSIBLE VERSION

N/A

CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

Referring to this thread: #32989

There seems to be an ability to use prompt->

  aireos_command:
        provider: "{{ creds }}"
        commands:
             - transfer download start
         prompt: "Are you sure you want to start\? \(y\/N\)"
         response: y
         wait_for: response[0] contains "File transfer is successful"

This looks like there is a command level parameter prompt. In the latest dev... I think this is actually documented on ios_command but not the others. We need to show some more examples in the module documentation, and possibly add something to the ansible networking guide as well, as this is a common ask.

STEPS TO REPRODUCE

N/A

EXPECTED RESULTS

N/A

ACTUAL RESULTS

N/A

@ansibot
Copy link
Contributor

ansibot commented Apr 23, 2018

@ansibot
Copy link
Contributor

ansibot commented Apr 23, 2018

@ansibot ansibot added affects_2.6 This issue/PR affects Ansible v2.6 docs This issue/PR relates to or includes documentation. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. networking Network category nxos Cisco NXOS community support:network This issue/PR relates to code supported by the Ansible Network Team. labels Apr 23, 2018
@ryansb ryansb removed the needs_triage Needs a first human triage before being processed. label Apr 24, 2018
@gundalow gundalow self-assigned this May 2, 2018
@gundalow gundalow changed the title document prompt ability for *os_command modules document prompt ability for *_command modules May 22, 2018
@gundalow
Copy link
Contributor

In addition:

@gundalow gundalow removed their assignment May 22, 2018
@gundalow gundalow changed the title document prompt ability for *_command modules Document prompt ability for network/*_command modules May 22, 2018
@sweenig
Copy link

sweenig commented Jul 3, 2018

Yes please, would like to see documentation on how multiple prompts can be used.

@gateszeng
Copy link

I think I have a potential workaround.
Although not completely the same, I believe if you know the exact responses that you'd have to give to the prompts then you can insert those responses after your command, separated by new line characters and double quotes surrounding the entire command.
I tried this on the enos_command module and it worked, although I'd imagine the same thing applies to the other command modules as well.

 - name: CHANGE PASSWORDS
   enos_command:
     provider: "{{ provider }}"
     commands:
       - enable
       - configure terminal
       - "access user 4 password\nADMIN_PASS\nNEW_PASS\nNEW_PASS"

@ansibot
Copy link
Contributor

ansibot commented Jul 10, 2018

@sweenig
Copy link

sweenig commented Jul 10, 2018

I tried this with ios_command a few minutes before you posted and it didn't work initially. Then i realized that everyone who had suggested this had put it in quotes and I hadn't. Make sure you try it with quotes.

@ansibot
Copy link
Contributor

ansibot commented Sep 18, 2018

@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed support:network This issue/PR relates to code supported by the Ansible Network Team. labels Sep 18, 2018
@ansibot ansibot added support:network This issue/PR relates to code supported by the Ansible Network Team. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 4, 2018
@ansibot
Copy link
Contributor

ansibot commented Feb 9, 2019

@dagwieers dagwieers added the cisco Cisco technologies label Feb 22, 2019
@ansibot ansibot added ios Cisco IOS community iosxr Cisco IOSXR community labels Feb 22, 2019
@dagwieers dagwieers added cisco Cisco technologies and removed cisco Cisco technologies labels Feb 22, 2019
@ansibot
Copy link
Contributor

ansibot commented Jun 22, 2019

@robdawg925
Copy link

robdawg925 commented Nov 27, 2019

Hey all,

Re-opening this thread, looking for some help.

Running Ansible 2.9.1

root@node-0:~# ansible --version
ansible 2.9.1
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/student/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.8 (default, Oct 7 2019, 12:59:55) [GCC 8.3.0]

I am trying to remove ‘feature npv’ on a Nexus switch. When running the command ‘no feature npv’ on the switch manually you get the following prompt:
Verify that boot variables are set and the changes are saved. Disabling npv mode erases the current configuration and reboots the switch in non-npv mode. Do you want to continue? (y/n):

Because I am not able to respond this prompt, when I run the ‘no feature npv’ command it times out. Below is my playbook:

  • name: Play 1
    hosts: ucs_5ks
    connection: local
    gather_facts: no
    tasks:

    • name: interface
      nxos_command:
      commands:
      - config t
      - no feature npv

Looking at this thread I also tried the following, but it still fails.

name: Play 1
hosts: ucs_5ks
connection: local
gather_facts: no
tasks:

  • name: interface
    nxos_command:
    commands:
    - config t
    - "no feature npv/ny"

I also tried using the nxos_feature module. My yaml file works for other features but does not work when I try enable/disable npv due to the prompt issues.

It also looks like I can't use 'prompt' when working with nxos_command.

Any ideas?

@chrisvanheuveln
Copy link
Contributor

This might work for avoiding the user prompt:

name: interface
nxos_config:
  lines: |
    term dont-ask
    no feature npv/ny
    no term dont-ask

Ref:
https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/6-x/command_reference/config_612I22/b_n9k_command_ref/b_n9k_command_ref_chapter_010110.html#wp3962612674

@robdawg925
Copy link

Thanks @chrisvanheuveln. Unfortunately looks like I still get the prompt.

PoD1-N5K-1(config)# term dont-ask
PoD1-N5K-1(config)# no feature npv
Verify that boot variables are set and the changes are saved. Disabling npv mode erases the current configuration and reboots the switch in non-npv mode. Do you want to continue? (y/n):

@ganeshrn
Copy link
Member

@sweenig You can use cli_command module that handles single as well as multiple prompts.

@robdawg925
The format for nxos_command module to handle prompt in this case is

  - name: run commands that require answering a prompt
    nxos_command:
      commands:
        - configure terminal
        - command: 'no feature npv'
          prompt: 'Do you want to continue'
          answer: 'y'

Note: The value of the prompt option is a Python regex hence special characters like ? should be handled with escape charterers if required.

@ganeshrn
Copy link
Member

needs_info

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Nov 29, 2019
@robdawg925
Copy link

@ganeshrn thanks. That worked! The command get executed on the switch. The only thing is the task in playbook gets a timeout error because the switch reboots write after the command.

@ansibot
Copy link
Contributor

ansibot commented Dec 31, 2019

@IPvSean This issue is waiting for your response. Please respond or the issue will be closed.

click here for bot help

@IPvSean
Copy link
Contributor Author

IPvSean commented Jan 10, 2020

@robdawg925 does this help? https://www.ansible.com/blog/rebooting-network-devices-with-ansible

use the reset

- name: reset the connection
  meta: reset_connection

@IPvSean
Copy link
Contributor Author

IPvSean commented Jan 10, 2020

this is a documentation bug, @samccann could we get examples from the blog post into module docs to help close this out?

@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label Jan 10, 2020
@ansible ansible locked and limited conversation to collaborators Feb 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.6 This issue/PR affects Ansible v2.6 cisco Cisco technologies docs This issue/PR relates to or includes documentation. ios Cisco IOS community iosxr Cisco IOSXR community module This issue/PR relates to a module. networking Network category nxos Cisco NXOS community support:network This issue/PR relates to code supported by the Ansible Network Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.