# Retrieving Cisco config with ios\_facts module results in extra data in saved file

**URL:** <https://forum.ansible.com/t/retrieving-cisco-config-with-ios-facts-module-results-in-extra-data-in-saved-file/30166>\
**Category:** Ansible Project\
**Created:** [April 23, 2019, 2:57am UTC](https://forum.ansible.com/t/retrieving-cisco-config-with-ios-facts-module-results-in-extra-data-in-saved-file/30166 "2019-04-23T02:57:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asilver](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@asilver](https://forum.ansible.com/u/asilver)\
**Post date:** [April 23, 2019, 2:57am UTC](https://forum.ansible.com/t/retrieving-cisco-config-with-ios-facts-module-results-in-extra-data-in-saved-file/30166/1 "2019-04-23T02:57:52Z")

</div>

Hello,  
I’m using the ios\_facts module and trying to retrieve the configuration from a Cisco CSR1000v. The configuration seems to be saved ok but the top of the file contains two lines that are invalid configuration commands. Thus, this file cannot be loaded into a router “as-is”. The two lines are “Building configuration” and “Current configuration: xxxx bytes”. These two lines typically show up when a user issues the “show run” from the cli. In my case, I’m trying to build to use the config to build on ISO start file. I’m pretty sure if I try and build an ISO configuration boot file with “invalid” commands. This file will not load.

`

- name: Step 1. Retrieve vCSR configuration using ios\_facts module  
connection: network\_cli  
ios\_facts:  
gather\_subset: config  
register: data  
when: ansible\_network\_os == ‘ios’

- name: Print Facts  
debug: msg={{ data.ansible\_facts.ansible\_net\_config }}  
`

Building configuration…

Current configuration : 8244 bytes  
!  
! Last configuration change at 01:43:37 UTC Tue Apr 23 2019 by cisco  
! NVRAM config last updated at 01:43:38 UTC Tue Apr 23 2019 by cisco  
!  
version 16.6  
service timestamps debug datetime msec  
service timestamps log datetime msec  
service call-home  
platform qfp utilization monitor load 80  
no platform punt-keepalive disable-kernel-core  
platform console serial

---

<div class="post-metadata">

**Author:** ![asilver](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@asilver](https://forum.ansible.com/u/asilver)\
**Post date:** [April 23, 2019, 2:52pm UTC](https://forum.ansible.com/t/retrieving-cisco-config-with-ios-facts-module-results-in-extra-data-in-saved-file/30166/2 "2019-04-23T14:52:52Z")

</div>

As a work around to this. After the config file is saved to Ansible server, I used the lineinfile module to remove those 2 configuration lines. With that being said, I still think this should be fixed unless someone has good reason why those 2 lines should be left in the saved config file…
