β 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?
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:
My register works fine with usual playbooks but the moment I use register
with with_together then no value is saved in variable?
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