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