- hosts: demo gather_facts: no tasks: - name: Gather posix account ansible.builtin.shell: cmd: > users=$(getent passwd | grep -v nologin | grep -v shutdown | awk -F":" '{ print $1 }');for i in $users; do last -w -F $i -1 | head -1 | grep -v ^$ | awk '{ print $1"@"$3"@"$5,$6,$7,$8 }';done register: result - name: Define info by set_fact ansible.builtin.set_fact: info: "{{ result.stdout_lines }}" - debug: var: info