diff --git a/lib/ansible/modules/network/cli/cli_command.py b/lib/ansible/modules/network/cli/cli_command.py index 778b397c0fc..2e04611448c 100644 --- a/lib/ansible/modules/network/cli/cli_command.py +++ b/lib/ansible/modules/network/cli/cli_command.py @@ -30,10 +30,14 @@ options: - A single regex pattern or a sequence of patterns to evaluate the expected prompt from I(command). required: false + type: list answer: description: - - The answer to reply with if I(prompt) is matched. + - The answer to reply with if I(prompt) is matched. The value can be a single answer + or a list of answer for multiple prompts. In case the command execution results in + multiple prompts the sequence of the prompt and excepted answer should be in same order. required: false + type: list sendonly: description: - The boolean value, that when set to true will send I(command) to the @@ -63,11 +67,23 @@ EXAMPLES = """ command: "{{ item }}" prompt: - "Exit with uncommitted changes" - answer: yes + answer: 'y' loop: - configure - set system syslog file test any any - exit + +- name: multiple prompt, multiple answer + cli_command: + command: "copy sftp sftp://user@host//user/test.img" + prompt: + - "Confirm download operation" + - "Password" + - "Do you want to change that to the standby image" + answer: + - 'y' + - + - 'y' """ RETURN = """ @@ -102,7 +118,7 @@ def main(): argument_spec = dict( command=dict(type='str', required=True), prompt=dict(type='list', required=False), - answer=dict(type='str', required=False), + answer=dict(type='list', required=False), sendonly=dict(type='bool', default=False, required=False), ) required_together = [['prompt', 'answer']]