# How do i save output of 2 TASKS to same file?

**URL:** <https://forum.ansible.com/t/how-do-i-save-output-of-2-tasks-to-same-file/35338>\
**Category:** Ansible Project\
**Created:** [June 12, 2021, 5:53pm UTC](https://forum.ansible.com/t/how-do-i-save-output-of-2-tasks-to-same-file/35338 "2021-06-12T17:53:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [June 12, 2021, 5:53pm UTC](https://forum.ansible.com/t/how-do-i-save-output-of-2-tasks-to-same-file/35338/1 "2021-06-12T17:53:51Z")

</div>

Hi,

In below script, i am saving backup of several router commands into a file using ‘copy’ module. Then i have written the script in such a way that EIGRP Neigbour backup should be taken only if EIGRP protcol is running and saved to another file.  
Is there any way i can save backup of both of these TASKS to same file?

- name: GATHER IP PROTOCOLS INFO  
ios\_command:  
commands: “show ip protocols”  
ignore\_errors: yes

register: show\_ip\_protocols

- name: TAKE BACKUP  
ios\_command:  
commands:
- show run
- show version
- sh ip int brief
- sh int description

register: device\_backup

- name: SAVE BACKUP TO A FILE NAMED WITH DEVICE HOSTNAME  
copy: content=“{{ device\_backup.stdout | join (‘\n’) }}” dest=“./iosupgrade/{{ ansible\_net\_hostname }}.txt”

- block:

- name: TAKE EIGRP NEIGBOUR BACKUP IF EIGRP PROTOCOL IS RUNNING  
ios\_command:  
commands:

- show ip eigrp nei

register: device\_backup2

- name: SAVE EIGRP BACKUP TO A FILE NAMED WITH DEVICE HOSTNAME  
copy: content=“{{ device\_backup2.stdout | join (‘\n’) }}” dest=“./iosupgrade/{{ ansible\_net\_hostname }}-eigrpBackup.txt”

when:

- “‘eigrp’ in show\_ip\_protocols.stdout[0]”

Thanks,  
Vikram
