ansible.builtin.expect (v2.4.6.0-1) — module

Executes a command and responds to prompts.

| "added in version" 2.0 of ansible.builtin"

Authors: Matt Martz (@sivel)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.4.6.0.post1

Description

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.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Case insensitve password string match
  expect:
    command: passwd username
    responses:
      (?i)password: "MySekretPa$$word"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Generic question with multiple different responses
  expect:
    command: /path/to/custom/command
    responses:
      Question:
        - response1
        - response2
        - response3

Inputs

    
echo:
    default: false
    description:
    - Whether or not to echo out your response strings.

chdir:
    description:
    - Change into this directory before running the command.

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.

removes:
    description:
    - A filename, when it does not exist, this step will B(not) be run.

timeout:
    default: 30
    description:
    - Amount of time in seconds to wait for the expected strings.

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