- shell: ls -alh'{{ item }}'
register:cmd_output
with_items:
- '/home/1'
- '/home/2'- debug:
msg: '{{ item.stdout }}'
when: ( '{{ item.cmd }}' == 'ls -alh /home/1' )
with_items: '{{ cmd_output.results }}'- shell: ls -alh'{{ item }}'
register:cmd_output
with_items:
- '/home/1'
- '/home/2'- debug:
msg: '{{ cmd_output.results | selectattr("cmd", "equalto", "ls -alh /home/1" ) | map(attribute="stdout") | join("") }}'