如何使用ansible将输入传递给交互式命令? [英] How to pass input to interactive command using ansible?
本文介绍了如何使用ansible将输入传递给交互式命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个要在 Unix 服务器上执行的命令.该命令期望用户在两个点输入,然后继续进行.命令如下:
I have a command to execute on Unix server. The command expect user input at two points and then proceed further. The command is like follows:
$ abc_1.2_udate.bin /tmp/log
Do you want to proceed y/n?
y
Please provide the credentials:
1234
从ansible尝试如下:
From ansible tried as follows:
- name: execute the cmnd
expect:
Command: abc_1.2_udate.bin /tmp/log
responses:
Do you want to proceed y/n? "y"
'Please provide the credentials:' "1234"
但是上面的部分不起作用.此外,我只想为此使用 expect 模块.
But the above piece does not work. Also I want to use expect module only for this.
推荐答案
- 将命令更改为命令(C 不是大写)
- 回复应该用引号括起来,格式为
'Enter': "y"
expect:
command: abc_1.2_udate.bin /tmp/log
responses:
'Do you want to proceed y/n?': "y"
'Please provide the credentials': "1234"
这篇关于如何使用ansible将输入传递给交互式命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文