user123892
user123892

Reputation: 1293

How to process a command asking for inputs with an Ansible task?

I'm learning Ansible and I'm wondering how to write a task to process the following command:

$<command> <options>

  username:
  email address:
  password:
  password (check):

The <command> <option> asks for four variables that can be hardcoded in the playbook.

Thank you for any insight you can provide

Upvotes: 3

Views: 5722

Answers (1)

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68239

Use expect module:

- hosts: localhost
  tasks:
    - expect:
        command: command option
        responses:
          username: "John Doe"
          email: "[email protected]"
          password: "mypass"

Upvotes: 4

Related Questions