New in version 2.0.
expect
module executes a command and responds to prompts.$HOME
and operations like "<"
, ">"
, "|"
, and "&"
will not work.The below requirements are needed on the host that executes this module.
Parameter | Choices/Defaults | Comments |
---|---|---|
chdir | Change into this directory before running the command. | |
command required | The command module takes command to run. | |
creates | A filename, when it already exists, this step will not be run. | |
echo | Default: no | Whether or not to echo out your response strings. |
removes | A filename, when it does not exist, this step will not be run. | |
responses required | 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 | Default: 30 | Amount of time in seconds to wait for the expected strings. Use null to disable timeout. |
Note
<
, >
, |
, etc), you must specify a shell in the command such as /bin/bash -c "/path/to/something | grep else"
.?i
.- 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
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/expect_module.html