ansible / ansible.builtin / v2.16.5 / module / expect Executes a command and responds to prompts | "added in version" 2.0 of ansible.builtin" Authors: Matt Martz (@sivel)ansible.builtin.expect (v2.16.5) — module
pip
Install with pip install ansible-core==2.16.5
The M(ansible.builtin.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 ansible.builtin.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 ansible.builtin.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 type: str 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 V(null) to disable timeout. type: raw 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