我正在尝试使用ansible在本地主机上安装kubectl,但是我得到了以下错误消息:
致命: localhost:"https://storage.googleapis.com/kubernetes-release/release/curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt
/bin/linux/amd64/kubectl"}!=> {“已更改”:false,"dest":"/temp/","msg":“发生了未知错误: URL不能包含控制字符。”https://storage.googleapis.com/kubernetes-release/release/curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt
/bin/linux/amd64/kubectl“}(至少找到‘')",”状态“:”缺席“,"url":”https://storage.googleapis.com/kubernetes-release/release/curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt
/bin/linux/amd64/kubectl“}
我相信问题可能与网址中的反勾字符有关。我试过用单引号和反斜杠包围他们,但他们没有起作用。这是我的剧本:
- hosts: localhost
become: yes
tasks:
- name: install kubectl
get_url:
url: https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
dest: /usr/local/bin/
mode: '0440'
发布于 2020-01-04 20:26:53
使用“shell”模块将curl的结果转换为变量,并在“get_url”模块中引用它:
- hosts: localhost
become: yes
tasks:
- name: get version
shell: curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt
register: version
- name: install kubectl
get_url:
url: "https://storage.googleapis.com/kubernetes-release/release/{{ version.stdout }}/bin/linux/amd64/kubectl"
dest: /usr/local/bin/
mode: '0440'
https://stackoverflow.com/questions/59593599
复制相似问题