title: Migration between with_items to loop
body: <p>I'm trying to migrate some code from with_items to loop.</p>
  
  <p>I have this playbook.yml. Seems they are the same but just changed the with_items to loop</p>
  
  <pre><code>- debug:  
      msg: "{{ item }}"
    loop:   
    - "{{ lookup('pipe','echo -e  \"pro.json\npre.json\ndev.json\"').split('\n') }}"
  
  - debug:  
      msg: "{{ item }}"
    with_items:
    - "{{ lookup('pipe','echo -e  \"pro.json\npre.json\ndev.json\"').split('\n') }}"
  </code></pre>
  
  <p>This is the output.</p>
  
  <pre><code>TASK [loop: debug] **********************************************************************************************************************************************************************************
  ok: [server] =&gt; (item=[u'pro.json', u'pre.json', u'dev.json']) =&gt; {
  "msg": [
      "pro.json", 
      "pre.json", 
      "dev.json"
  ]
  }
  
      TASK [with_items : debug] **********************************************************************************************************************************************************************************
  Ok: [server] =&gt; (item=pro.json) =&gt; {
      "msg": "pro.json"
  }
  ok: [server] =&gt; (item=pre.json) =&gt; {
      "msg": "pre.json"
  }
  ok: [server] =&gt; (item=dev.json) =&gt; {
      "msg": "dev.json"
  }
  </code></pre>
  
  <p>As you see loop keeps the output in a kind of chain and with_items split it in three outputs.</p>
  
  <p>I need change the ouput of loop, to look like the with_items. What I want is create a loop that give me a list, depend on the list this loop will be looping.</p>
  
  <p>The with_items result will loop three or as many as the pipe command does but loop only will one</p>
  
  <p>EDIT: </p>
  
  <p>I have tried the with sequence solution for loop and seems this is posible but I cannot change my code to work like.</p>
  
  <p><a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html?highlight=loop#with-sequence" rel="nofollow noreferrer">https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html?highlight=loop#with-sequence</a></p>
  
  <pre><code>TASK [: with_sequence] **************************************************************************************************************************************************************************
  ok: [server] =&gt; (item=testuser00) =&gt; {
      "msg": "testuser00"
  }
  ok: [server] =&gt; (item=testuser02) =&gt; {
      "msg": "testuser02"
  }
  ok: [server] =&gt; (item=testuser04) =&gt; {
      "msg": "testuser04"
  }
  
  TASK [: with_sequence -&gt; loop] ******************************************************************************************************************************************************************
  ok: [server] =&gt; (item=0) =&gt; {
      "msg": "testuser00"
  }
  ok: [server] =&gt; (item=2) =&gt; {
      "msg": "testuser02"
  }
  ok: [server] =&gt; (item=4) =&gt; {
      "msg": "testuser04"
  }
  </code></pre>