- name: create file to write in become: false command: touch output.txt - name: call apt update become: true shell: apt update register: os_info - name: write to output.txt copy: content: "{{os_info.stdout_lines}}" dest: output.txt - debug: msg: "{{os_info.stdout_lines}}"