title: Ansible how to skip the loop if the list is empty
body: <p>I'm running Ansible and I try to make this task work. I have defined the default of the variable "docker_registries" to be an empty list: <code>docker_registries: []</code> I noticed that I will get error when running the ansible playbook if the list is empty. this is the error I get: </p>
  
  <blockquote>
    <p>fatal: [***.cloudapp.azure.com]: FAILED! => {"msg": "Invalid data passed to 'loop', it requires a list, got this instead: None. 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."}</p>
  </blockquote>
  
  <p>I'm trying to add the condition that if the "docker_registries" is empty the task continues without raising an error.
   this is the code for this task:  </p>
  
  <pre><code>- name: Log into additional docker registries, when required
    command: docker login -u {{item.username}} -p {{item.password}} {{item.server}}
    become: true
    loop: "{{docker_registries}}"
  </code></pre>
  
  <p>I tried to change the loop to   <code>loop: "{{ lookup(docker_registries, {'skip_missing': True})}}"</code>
  but I get the error</p>
  
  <blockquote>
    <p>An exception occurred during task execution. To see the full
    traceback, use -vvv. The error was: AttributeError: 'NoneType' object
    has no attribute 'lower' fatal:
    [***.cloudapp.azure.com]: FAILED! =>
    {"msg": "Unexpected failure during module execution.", "stdout": ""}</p>
  </blockquote>
  
  <p>I'm pretty new with this. Can anyone help?</p>