如何使用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屋!
查看全文