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

旧街凉风 提交于 2019-12-24 00:23:43

问题


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


回答1:


Use expect module:

- hosts: localhost
  tasks:
    - expect:
        command: command option
        responses:
          username: "John Doe"
          email: "joh@doe.com"
          password: "mypass"


来源:https://stackoverflow.com/questions/38264206/how-to-process-a-command-asking-for-inputs-with-an-ansible-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!