我试着用ansible下载Istio。在这里,我使用了以下结构。
- name: Download Istio
command: curl https://istio.io/downloadIstio | sh -
- name: Start minikube
command: minikube start
但当我运行命令时它会返回,
fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["curl", "https://istio.io/downloadIstio", "|", "sh", "-"], "delta": "0:00:00.005276", "end": "2019-11-20 11:32:17.749051", "msg": "non-zero return code", "rc": 2, "start": "2019-11-20 11:32:17.743775", "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": []}
如何解决这个问题?
发布于 2019-11-19 23:24:56
命令将不会通过shell进行处理,因此像$HOME这样的变量和诸如"<“、">”、“\”、“和&”之类的操作将无法工作。如果需要这些特性,可以使用shell模块。
相反,使用“外壳”模块
- name: Download Istio
shell: curl https://istio.io/downloadIstio | sh -
发布于 2019-11-20 04:06:11
命令模块不支持扩展的shell语法,比如管道和重定向(尽管shell变量总是工作的)。如果命令需要特定于shell的语法,则使用shell模块。
请考虑使用url模块
将文件从HTTP、HTTPS或FTP下载到远程服务器。远程服务器必须直接访问远程资源。您可以将其与shell模块结合起来:
作为一个例子,请看一下这个社区范例
- name: Download zsh installer
get_url: url=https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh dest=/tmp/zsh-installer.sh
- name: Execute the zsh-installer.sh
shell: /tmp/zsh-installer.sh
https://stackoverflow.com/questions/58947800
复制