title: Ansible loop error: "Invalid data passed to 'loop', it requires a list, got this instead
body: <p>I am trying to download the images in the remote sever by executing the below ansible playbook, however I am struck with the following error. Could anyone help me in resolving this issue.</p>
  <p>Ansible-playbook:</p>
  <pre><code>name: download images from http
  hosts: target1
  tasks:
    - name: download the images
      get_url:
        url: &quot;{{ item }}&quot;
        dest: /home/ubuntu
      when: ansible_user== 'ubuntu'
      loop: &quot;{{lookup('file', '/home/ubuntu/file.txt')}}&quot;
  </code></pre>
  <p>error:</p>
  <p>fatal: [target1]: FAILED! =&gt; {&quot;msg&quot;: &quot;Invalid data passed to 'loop', it requires a list, got this instead: <a href="https://test.s3.eu-central-1.amazonaws.com/gm.mp4%5Cnhttps://test.s3.eu-central-1.amazonaws.com/ge.mp4" rel="nofollow noreferrer">https://test.s3.eu-central-1.amazonaws.com/gm.mp4\nhttps://test.s3.eu-central-1.amazonaws.com/ge.mp4</a> Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup.&quot;}</p>
  <p>file.txt:</p>
  <pre><code>https://test.s3.eu-central-1.amazonaws.com/gm.mp4
  https://test.s3.eu-central-1.amazonaws.com/ge.mp4
  </code></pre>