<p>I'm trying to install kubectl in my localhost using ansible, but i get the  below error message:</p>

<blockquote>
  <blockquote>
    <p>fatal: [localhost]: FAILED! => {"changed": false, "dest": "/temp/", "msg": "An unknown error occurred: URL can't contain control characters. '/kubernetes-release/release/<code>curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt</code>/bin/linux/amd64/kubectl' (found at least ' ')", "state": "absent", "url": "<a href="https://storage.googleapis.com/kubernetes-release/release/" rel="nofollow noreferrer">https://storage.googleapis.com/kubernetes-release/release/</a><code>curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt</code>/bin/linux/amd64/kubectl"}</p>
  </blockquote>
</blockquote>

<p>I believe the issue might be with the back-tick characters in the url. I have tried surrounding them with single quotes and backslashes, but they didn't work. 
Here is my playbook:</p>

<p></p>

<pre><code>- 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'
</code></pre>

cmoe
<p>Get the result of curl into variable using 'shell' module, and reference it in the 'get_url' module:</p>

<pre><code>- 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'
</code></pre>
