如何使用 Ansible 任务处理要求输入的命令? [英] How to process a command asking for inputs with an Ansible task?

查看:25
本文介绍了如何使用 Ansible 任务处理要求输入的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 Ansible,我想知道如何编写一个任务来处理以下命令:

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):

<代码><命令><option> 要求四个可以在剧本中硬编码的变量.

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

感谢您提供的任何见解

推荐答案

使用 expect 模块:

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

这篇关于如何使用 Ansible 任务处理要求输入的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆