New in version 2.0.
expect
module executes a command and responds to prompts.$HOME
and operations like "<"
, ">"
, "|"
, and "&"
will not work.parameter | required | default | choices | comments |
---|---|---|---|---|
chdir | no | Change into this directory before running the command. | ||
command | yes | The command module takes command to run. | ||
creates | no | A filename, when it already exists, this step will not be run. | ||
echo | no | Whether or not to echo out your response strings. | ||
removes | no | A filename, when it does not exist, this step will not be run. | ||
responses | yes | 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. | ||
timeout | no | 30 | Amount of time in seconds to wait for the expected strings. |
- name: Case insensitve password string match expect: command: passwd username responses: (?i)password: "MySekretPa$$word" - name: Generic question with multiple different responses expect: command: /path/to/custom/command responses: Question: - response1 - response2 - response3
Note
<
, >
, |
, etc), you must specify a shell in the command such as /bin/bash -c "/path/to/something | grep else"
.?i
.This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/expect_module.html