ansible / ansible.builtin / v2.9.7 / module / expect Executes a command and responds to prompts. | "added in version" 2.0 of ansible.builtin" Authors: Matt Martz (@sivel) preview | supported by communityansible.builtin.expect (v2.9.7) — module
pip
Install with pip install ansible==2.9.7
The C(expect) module executes a command and responds to prompts.
The given command will be executed on all selected nodes. It will not be processed through the shell, so variables like C($HOME) and operations like C("<"), C(">"), C("|"), and C("&") will not work.
- name: Case insensitive password string match expect: command: passwd username responses: (?i)password: "MySekretPa$$word" # you don't want to show passwords in your logs no_log: true
- name: Generic question with multiple different responses expect: command: /path/to/custom/command responses: Question: - response1 - response2 - response3
echo: default: false description: - Whether or not to echo out your response strings. type: bool chdir: description: - Change into this directory before running the command. type: path command: description: - The command module takes command to run. required: true creates: description: - A filename, when it already exists, this step will B(not) be run. type: path removes: description: - A filename, when it does not exist, this step will B(not) be run. type: path timeout: default: 30 description: - Amount of time in seconds to wait for the expected strings. Use C(null) to disable timeout. type: int responses: description: - Mapping of expected string/regex and string to respond with. If the response is a list, successive matches return successive responses. List functionality is new in 2.1. required: true type: dict