From db4ae20e8b0b780a9499ff62fa96ed8e2c5ba83c Mon Sep 17 00:00:00 2001 From: Tyler Bigler Date: Wed, 16 May 2018 10:39:07 -0400 Subject: [PATCH] ios_command: Correct answer example and consolidate docs on command param. (#40158) * Correct answer example as 'c' cancels, not confirms. Moved command note to be in line with command docs. * Correct example to escape square brackets. Remove '\r' mention as it does not get passed correctly. * Add carriage return example since it works with double quotes. * Remove colon which was breaking docs rendering. --- .../modules/network/ios/ios_command.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ansible/modules/network/ios/ios_command.py b/lib/ansible/modules/network/ios/ios_command.py index 8aae27ed159..16b14801f54 100644 --- a/lib/ansible/modules/network/ios/ios_command.py +++ b/lib/ansible/modules/network/ios/ios_command.py @@ -37,8 +37,6 @@ 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: @@ -46,7 +44,11 @@ options: configured provider. The resulting output from the command is returned. If the I(wait_for) argument is provided, the module is not returned until the condition is satisfied or - the number of retries has expired. + the number of retries has expired. 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). + Common answers are 'y' or "\\r" (carriage return, must be + double quotes). See examples. required: true wait_for: description: @@ -84,7 +86,7 @@ options: default: 1 """ -EXAMPLES = """ +EXAMPLES = r""" tasks: - name: run show version on remote devices ios_command: @@ -109,12 +111,15 @@ tasks: wait_for: - result[0] contains IOS - result[1] contains Loopback0 - - name: run command that requires answering a prompt + - name: run commands that require answering a prompt ios_command: commands: + - command: 'clear counters GigabitEthernet0/1' + prompt: 'Clear "show interface" counters on this interface \[confirm\]' + answer: 'y' - command: 'clear counters GigabitEthernet0/2' - prompt: 'Clear "show interface" counters on this interface [confirm]' - answer: c + prompt: '[confirm]' + answer: "\r" """ RETURN = """