Combine values from multiple lists

How would I go about printing the values from three lists, so that each line contains elements from each list? For instance, I can print the values from the lists using:

msg:

  • “Memory: {{ memoryLocator.stdout_lines }}”

  • “Memory: {{ memoryPN.stdout_lines }}”

  • “Memory: {{ memorySN.stdout_lines }}”

This would print the values like:

DIMM1

DIMM2

DIMM3

G55555-111

G55555-111

G55555-111

999000123

999000440

999000554

However, what I would like to do is print the lists so each line of the output would combine

DIMM1 G55555-111 999000123

DIMM1 G55555-111 999000440

DIMM1 G55555-111 999000554

Sorry, the output should be:

DIMM1 G55555-111 999000123

DIMM2 G55555-111 999000440

DIMM3 G55555-111 999000554

Check out with_together
https://docs.ansible.com/ansible/2.4/playbooks_loops.html#looping-over-parallel-sets-of-data

Thanks, that worked well. I am writing this information to a file using lineinfile. How would I strip off the brackets, quotes and commas?
[‘DIMM1’, ‘G55555-111’, ‘999000123’]

I'm not sure what you do, but with_together don't produce a list, that must be something you do so just don't do that.

Sorry, the output is from stdout_lines. here is the section.

  • lineinfile:
    line: “{{ item }}”
    path: “{{ log }}”

with_together:

  • “{{ memoryLocator.stdout_lines }}”

  • “{{ memoryPN.stdout_lines }}”

  • “{{ memorySN.stdout_lines }}”

The output to the log:
[‘DIMM1’, ‘G55555-111’, ‘999000123’]
[‘DIMM2’, ‘G55555-111’, ‘999000440’]
[‘DIMM3’, ‘G55555-111’, ‘999000554’]

I would like to just have:

DIMM1 G55555-111 999000123
DIMM2 G55555-111 999000440
DIMM3 G55555-111 999000554

Change line to
  line: "{{ item.0 }} {{ item.1 }} {{ item.2 }}"

This worked thanks