title: Ansible Debug msg redirection as a file
body: <p>I am looking for some directions to fix an issue where i am not able to save or redirect the Ansible debug output to a JSON or md file.</p>
  
  <pre><code>    - debug:
          msg: 
           - "{{ item.results['show ip route'].splitlines() }}"  
           - "{{ item.results['show ip route summary'].splitlines() }}"
           - "{{ item.results['show ip route 0.0.0.0'].splitlines() }}"
  
        loop:
          - "{{ out2 }}"
  </code></pre>
  
  <p>The above mentioned debug module runs at the very end of my playbook. The playbook mainly uses "napalm_cli" network module to collect few outputs from a device. The "napalm_cli" module output is not nicely formatted,so, i have to use splitlines. </p>
  
  <p>Now i am trying to save below output as a file </p>
  
  <pre><code>ok: [lab1-r1] =&gt; (item={'failed': False, u'changed': False, u'results': {u'show ip route': u'Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP\n       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area \n       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2\n       E1 - OSPF external type 1, E2 - OSPF external type 2\n       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2\n       ia - IS-IS inter area, * - candidate default, U - per-user static route\n       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP\n       a - application route\n       + - replicated route, % - next hop override, p - overrides from PfR\n\nGateway of last resort is not set\n\n      172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks\nC        172.16.10.0/24 is directly connected, GigabitEthernet0/1\nL        172.16.10.1/32 is directly connected, GigabitEthernet0/1', u'show ip route summary': u'IP routing table name is default (0x0)\nIP routing table maximum-paths is 32\nRoute Source    Networks    Subnets     Replicates  Overhead    Memory (bytes)\nconnected       0           2           0           136         360\nstatic          0           0           0           0           0\napplication     0           0           0           0           0\ninternal        1                                               440\nTotal           1           2           0           136         800', u'show ip route 0.0.0.0': u'% Network not in table'}}) =&gt; {
  "msg": [
      [
          "Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP", 
          "       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area ", 
          "       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2", 
          "       E1 - OSPF external type 1, E2 - OSPF external type 2", 
          "       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2", 
          "       ia - IS-IS inter area, * - candidate default, U - per-user static route", 
          "       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP", 
          "       a - application route", 
          "       + - replicated route, % - next hop override, p - overrides from PfR", 
          "", 
          "Gateway of last resort is not set", 
          "", 
          "      172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks", 
          "C        172.16.10.0/24 is directly connected, GigabitEthernet0/1", 
          "L        172.16.10.1/32 is directly connected, GigabitEthernet0/1"
      ], 
      [
          "IP routing table name is default (0x0)", 
          "IP routing table maximum-paths is 32", 
          "Route Source    Networks    Subnets     Replicates  Overhead    Memory (bytes)", 
          "connected       0           2           0           136         360", 
          "static          0           0           0           0           0", 
          "application     0           0           0           0           0", 
          "internal        1                                               440", 
          "Total           1           2           0           136         800"
      ], 
      [
          "% Network not in table"
      ]
  ]
  }
  </code></pre>
  
  <p>Also, i would like to get rid of the content between </p>
  
  <pre><code>ok: [lab1-r1] =&gt;   napalm_cli non formatted output
  "msg": [
  </code></pre>
  
  <p>Any ideas or thoughts. </p>
  
  <p>Thank You</p>
  
  <p>NN</p>