From 875c1343a9f5887566c9de4d64557991cc12134c Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Mon, 5 Feb 2018 04:13:43 -0800 Subject: [PATCH] Document the multiline prompt/answer format for ios commands (#35716) * Document the multiline prompt/answer format for ios commands Fixes #34468 * Put a note * Add also docs for vyos --- lib/ansible/modules/network/ios/ios_command.py | 8 ++++++++ lib/ansible/modules/network/vyos/vyos_command.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/ansible/modules/network/ios/ios_command.py b/lib/ansible/modules/network/ios/ios_command.py index 0729a761f61..e1ead254432 100644 --- a/lib/ansible/modules/network/ios/ios_command.py +++ b/lib/ansible/modules/network/ios/ios_command.py @@ -37,6 +37,8 @@ description: extends_documentation_fragment: ios notes: - Tested against IOS 15.6 + - If a command sent to the device requires answering a prompt, it is possible + to pass a dict containing I(command), I(answer) and I(prompt). See examples. options: commands: description: @@ -112,6 +114,12 @@ tasks: wait_for: - result[0] contains IOS - result[1] contains Loopback0 + - name: run command that requires answering a prompt + ios_command: + commands: + - command: 'clear counters GigabitEthernet0/2' + prompt: 'Clear "show interface" counters on this interface [confirm]' + answer: c """ RETURN = """ diff --git a/lib/ansible/modules/network/vyos/vyos_command.py b/lib/ansible/modules/network/vyos/vyos_command.py index 798ec0077a9..55d02fce069 100644 --- a/lib/ansible/modules/network/vyos/vyos_command.py +++ b/lib/ansible/modules/network/vyos/vyos_command.py @@ -89,6 +89,8 @@ notes: - Tested against VYOS 1.1.7 - Running C(show system boot-messages all) will cause the module to hang since VyOS is using a custom pager setting to display the output of that command. + - If a command sent to the device requires answering a prompt, it is possible + to pass a dict containing I(command), I(answer) and I(prompt). See examples. """ EXAMPLES = """ @@ -108,6 +110,13 @@ tasks: - show hardware cpu wait_for: - "result[0] contains 'VyOS 1.1.7'" + + - name: run command that requires answering a prompt + vyos_command: + commands: + - command: 'rollback 1' + prompt: 'Proceed with reboot? [confirm][y]' + answer: y """ RETURN = """