register with with_together not working

I want to use register with loops (http://docs.ansible.com/ansible/playbooks_loops.html#using-register-with-a-loop) to accomplish below tasks:

– Surf through couple of variables arrays in with_together format and save result to a variable
– now surf through that result set variable and perform specific action.

My register works fine with usual playbooks but the moment I use register with with_together then no value is saved in variable? :frowning:

My playbook:

  • name: check for port on remote host
    hosts: localhost
    connection: local
    vars_files:
  • vars1.yml

tasks:

  • name: check for ports
    debug: msg=β€œx is {{ item.0 }}, y is {{ item.1 }} and z is {{ item.2 }}”
    with_together:

  • β€œ{{ x }}”

  • β€œ{{ y }}”

  • β€œ{{ z }}”
    register: result

  • debug: var=result.stdout_lines

My Variables File:

My register works fine with usual playbooks but the moment I use register
with with_together then no value is saved in variable? :frowning:

That's because all the with_ that combines data have a different schema than ordinary register.

*My playbook:*
- name: check for port on remote host
  hosts: localhost
  connection: local
  vars_files:
    - vars1.yml

  tasks:
    - name: check for ports
      debug: msg="x is {{ item.0 }}, y is {{ item.1 }} and z is {{ item.2
}}"
      with_together:
        - "{{ x }}"
        - "{{ y }}"
        - "{{ z }}"
      register: result

    - debug: var=result.stdout_lines

Try
   - debug: var=result
instead and you will see that the schema is different for the with_'s

Any time you use with_ (loops) you’ll get a β€˜results’ key with a list of the normal task results per item of the loop.