我想用 Ansible 运行安装程序脚本。安装程序脚本会提示一些响应,并且需要以 root 权限运行。
这是我的 Ansible 任务的本质:
- expect:
become: yes
become_method: sudo
command: "installer.bin"
echo: yes
responses:
"Choose the appropriate installation or upgrade option.": "2"
"Where should the software be installed?": "/opt/newsoftware/"
Run Code Online (Sandbox Code Playgroud)
我原以为这会奏效,但我收到错误
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: become_method"}
Run Code Online (Sandbox Code Playgroud)
如果我省略“become_method”,则会出现此错误:
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: become"}
Run Code Online (Sandbox Code Playgroud)
我的 Ansible 是 2.1.1.0 版
我认为你需要写这样的任务:
- expect:
become: yes
become_method: sudo
args:
command: "installer.bin"
echo: yes
responses:
"Choose the appropriate installation or upgrade option.": "2"
"Where should the software be installed?": "/opt/newsoftware/"
Run Code Online (Sandbox Code Playgroud)
你可以省略become_method
.
归档时间: |
|
查看次数: |
3333 次 |
最近记录: |