Macos 无法在Ansible中运行CURL命令

Macos 无法在Ansible中运行CURL命令,macos,curl,ansible,istio,Macos,Curl,Ansible,Istio,我试图用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://

我试图用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": []}
如何解决此问题?

来自:

命令将不会通过shell进行处理,因此 像$HOME和像“,”和“&”这样的操作将不会 工作如果需要这些功能,请使用shell模块

相反,请使用以下命令:

根据ansible和Zeitounator:

命令模块不支持诸如管道和重定向之类的扩展shell语法(尽管shell变量始终有效)。如果命令需要特定于shell的语法,请改用shell模块

请考虑使用:

将文件从HTTP、HTTPS或FTP下载到远程服务器。远程服务器必须能够直接访问远程资源。 您可以将其与外壳模块结合使用:

作为示例,请查看以下内容:


除此之外,在这种简单的情况下(获取远程内容),不要在shell中使用curl,而是使用or模块
- name: Download Istio
  shell: curl https://istio.io/downloadIstio | sh -
- 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