1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add support for multiple answers in cli_command module (#44560)

* Add support for multiple answers in cli_command module

*  Add multiple answers support for multiple prompts

Depends on PR #44492

* Doc update
This commit is contained in:
Ganesh Nalawade 2018-08-23 19:19:18 +05:30 committed by Nathaniel Case
parent 6c05e03fea
commit 64045cb024

View file

@ -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'
- <password>
- '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']]