you might want to use stdout_lines but it would be better to use the https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_config_module.rst#ciscoiosxriosxr_config module with the backup parameter, as this should do the job for you.
On Monday, 22 March 2021 at 20:30:32 UTC jarr...@gmail.com wrote: > i get wrong format below is my script: > --- > - name: BACKUP ROUTER CONFIGURATIONS > hosts: all > connection: local > gather_facts: false > vars: > data_dir: foo > tasks: > - name: BACKUP THE CONFIG > iosxr_command: > commands: > #- { command: show run } > - { command: show logging | ex SSH } > - { command: show ospf neighbor } > - { command: show bgp all all summary } > - { command: show mpls ldp neighbor } > register: config_output > > - name: RENAME BACKUP > copy: > content: "{{ config_output.stdout }}" > dest: "/var/lib/awx/projects/XR-ISP-GW-showOSPF/LOGFILE/{{ > inventory_hostname }}.txt" > i got something like this: > > nAddress Family: IPv4 Unicast\n----------------------------\n\nBGP router > identifier 89.211.1.7, local AS number 8781\nBGP generic scan interval 60 > secs\nNon-stop routing is enabled\nBGP table state: Active\nTable ID: > 0xe0000000 RD version: 1579942429\nBGP main routing table version > 1579942429\nBGP NSR Initial initsync version 395208 (Reached)\nBGP NSR/ISSU > Sync-Group versions 1579942429/0\nBGP scan interval 60 secs\n\nBGP is > operating in STANDALONE mode.\n\n\nProcess RcvTblVer bRIB/RIB > LabelVer ImportVer SendTblVer StandbyVer\nSpeaker 1579942429 > 1579942429 1579942429 1579942429 1579942429 1579942429\n\nNeighbor > Spk AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down > St/PfxRcd\n72.14.198.144 0 15169 3847027 3304487 1579942429 0 0 > 29w3d 985\n72.14.211.141 0 15169 3994770 3430527 1579942429 > 0 0 23w2d 985\n82.148.106.13 0 16509 3955040 3453340 > 1579942429 0 0 3w0d 1405\n82.148 > > _________________________________________________________________________________________________________________________ > how can it be solved? > On Monday, February 8, 2021 at 8:13:22 PM UTC+3 Vikram S wrote: > >> Yes, removing [0] worked!! >> I am learning ansible using a udemy tutorial and i am practising sample >> playbook in tutorial in GNS3. I am not sure why it worked for the author to >> save output of multiple commands with [0] present. It's a 3 yr old course, >> probably something changed in ansible recently. >> >> On Monday, 8 February, 2021 at 8:00:23 pm UTC+5:30 Brian Coca wrote: >> >>> This will only print the first element of 'stdout', remove the [0] to >>> get the full thing. >>> >>> print_output.stdout[0] >>> >>> vs >>> >>> print_output.stdout >>> >>> -- >>> ---------- >>> Brian Coca >>> >>> -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d7e6ccce-69d0-44b0-8588-cafdf1448a6an%40googlegroups.com.