Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Ansible:“;URL可以';“不包含控制字符”;_Linux_Kubernetes_Ansible - Fatal编程技术网

Linux Ansible:“;URL可以';“不包含控制字符”;

Linux Ansible:“;URL可以';“不包含控制字符”;,linux,kubernetes,ansible,Linux,Kubernetes,Ansible,我试图使用ansible在本地主机中安装kubectl,但收到以下错误消息: 致命:[localhost]:失败!=>{“changed”:false,“dest”:“/temp/”,“msg”:“出现未知错误:URL不能包含控制字符。”/kubernetes release/release/curl-shttps://storage.googleapis.com/kubernetes-release/release/stable.txt/bin/linux/amd64/kubectl'(至少找

我试图使用ansible在本地主机中安装kubectl,但收到以下错误消息:

致命:[localhost]:失败!=>{“changed”:false,“dest”:“/temp/”,“msg”:“出现未知错误:URL不能包含控制字符。”/kubernetes release/release/
curl-shttps://storage.googleapis.com/kubernetes-release/release/stable.txt
/bin/linux/amd64/kubectl'(至少找到“”),“状态”:“缺席”,“url”:“
curl-shttps://storage.googleapis.com/kubernetes-release/release/stable.txt
/bin/linux/amd64/kubectl“}

我相信这个问题可能与url中的反勾号有关。我曾尝试用单引号和反斜杠将它们括起来,但都不起作用。 这是我的剧本:

- 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'


使用“shell”模块获取curl into变量的结果,并在“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'

使用“shell”模块获取curl into变量的结果,并在“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'

你说得对,
curl-shttps://storage.googleapis.com/kubernetes-release/release/stable.txt那里不允许使用
-您的语法是用于shell脚本的,ansible无法使用该语法。您需要在另一个任务中将它放到一个变量中,将它注册到一个变量中,并在发布的任务中使用该变量,使用
{}
.vars:url\u path:“curl-s”url:{{url\u path}/bin/linux/amd64/kubectl。我只是尝试了一下,但没有成功。我尝试使用shell,但得到了使用get\u url或uri模块的警告。我继续使用了一个特定的版本。”“相反。根据医生的说法,有背杆的那个会给我一个稳定的版本。你是对的,
curl-shttps://storage.googleapis.com/kubernetes-release/release/stable.txt那里不允许使用
——您的语法是用于shell脚本的,ansible无法使用它。您需要使用另一个任务将其获取到一个变量,将其注册到一个变量,并在发布的任务中使用该变量,使用
{{}
.vars:url\u path:“curl-s”url:{{{url\u path}}/bin/linux/amd64/kubectl。我只是试过了,但没用。我尝试使用shell,但得到了使用get_url或uri模块的警告。我继续使用了特定的版本“”。根据医生的说法,有背杆的那个会给我一个稳定的版本。