我必须卸载一个软件,在卸载该软件时,它会提示我以yes or no的身份寻求答案。给出下面的示例。
# /opt/altiris/notification/nsagent/bin/aex-uninstall
This will remove the Symantec Management Agent for UNIX, Linux and Mac software from your system.
Are you sure you want to continue [Yy/Nn]?现在,由于我有多个Linux系统来做这件事,所以我正在寻找ansible来为我做这项工作,所以,我刚刚测试了ansible的adhoc方式,如下所示,它与shell模块一起工作…
# ansible all -m shell -a 'echo "y" | /opt/altiris/notification/nsagent/bin/aex-uninstall'
dev-karn | SUCCESS | rc=0 >>
This will remove the Symantec Management Agent for UNIX, Linux and Mac software from your system.
Are you sure you want to continue [Yy/Nn]?
Uninstalling dependant solutions...
Uninstalling dependant solutions finished.
Removing Symantec Management Agent for UNIX, Linux and Mac package from the system...
Removing wrapper scripts and links for applications...
Sending uninstall events to NS
Stopping Symantec Management Agent for UNIX, Linux and Mac: [ OK ]
Remove non packaged files.
Symantec Management Agent for UNIX, Linux and Mac Configuration utility.
Removing aex-* links in /usr/bin
Removing RC init links and scripts
Cleaning up after final package removal.
Removal finished.有没有更好的办法...任何想法都将非常受欢迎。
发布于 2017-12-12 17:53:55
您应该使用Ansible expect模块。
发布于 2017-12-12 23:06:36
linux shell的yes实用程序反复输出y,它满足了每一个预先回答的程序都需要通过程序进行提示,从而满足了我的需求,因为我正在运行的程序只需要答案是yes就可以继续进行,因此我将其与ansible shell模块一起使用如下所示...
$ ansible all -m shell -a '/bin/yes | /opt/altiris/notification/nsagent/bin/aex-uninstall'因此,即使是echo "y"也不是必需的。
Thnx - Karn
https://stackoverflow.com/questions/47766151
复制相似问题