Retrieving Cisco config with ios_facts module results in extra data in saved file

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

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…