我想通过Ansible发出命令:
curl -sL https://deb.nodesource.com/setup | sudo bash -
Run Code Online (Sandbox Code Playgroud)
我怎么能通过Ansible做到这一点?我现在有:
- name: Add repository
command: curl -sL https://deb.nodesource.com/setup | sudo bash -
Run Code Online (Sandbox Code Playgroud)
但它抛出错误:
[WARNING]: Consider using get_url or uri module rather than running curl
Run Code Online (Sandbox Code Playgroud)
fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": ["curl", "-sL", "https://deb.nodesource.com/setup", "|", "sudo", "bash", "-"], "delta": "0:00:00.006202", "end": "2017-12-27 15:11:55.441754", "msg": "non-zero return code", "rc": 2, "start": "2017-12-27 15:11:55.435552", "stderr": "curl: option -: is unknown\ncurl: try 'curl --help' or 'curl --manual' for more information", "stderr_lines": ["curl: option -: is unknown", "curl: try 'curl --help' or 'curl --manual' for more information"], "stdout": "", "stdout_lines": []}
您可以:
- name: Add repository
shell: curl -sL https://deb.nodesource.com/setup | sudo bash -
args:
warn: no
Run Code Online (Sandbox Code Playgroud)
shell允许管道,warn: no抑制警告.
但如果我是你,我会使用apt_key+ apt_repositoryAnsible模块创建自我解释的剧本,也支持check_mode运行.
| 归档时间: |
|
| 查看次数: |
4257 次 |
| 最近记录: |