diff --git a/lib/ansible/modules/network/ios/ios_command.py b/lib/ansible/modules/network/ios/ios_command.py index 0729a761f6..e1ead25443 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 798ec0077a..55d02fce06 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 = """