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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e6c5e481-a459-4b3a-9bb4-acf36d56f41dn%40googlegroups.com.

Reply via email to