我想用Ansible运行一个安装脚本。 安装程序脚本提示input许多响应,并要求以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/"
我会认为这会工作,但我得到的错误
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: become_method"}
如果我省略“become_method”,我得到这个错误:
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: become"}
我的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/"
你可以省略become_method 。