--- - hosts: all tasks: - name: run report script: pkgReport.py {{ inventory_hostname }} register: report - name: build local report lineinfile: path: "/tmp/pkgReport.txt" insertafter: EOF line: "{{ item }}" state: present create: yes with_items: "{{ report.stdout.lines }}" delegate_to: 127.0.0.1