Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Compare and apply differences on configuration file

by cord-bin (Pilgrim)
on May 06, 2014 at 08:49 UTC ( #1085150=perlquestion: print w/ replies, xml ) Need Help??
cord-bin has asked for the wisdom of the Perl Monks concerning the following question:

Hi I need to create a script to update a cisco ASA firewall in a backup site. During the day admins modify the configuration on the main site and I need to update de backup site. So I should be able to take the configuration file from the main site, parse it, change the IP's and apply the differences to the backup site. The backup site is a copy of the main site but has different IP address namespace. The thing is that ASA has 3 kinds of settings:
  • in one line like

  • where I have to change the IP address that I need to map it so 172.20.20.125 became 172.10.10.125
    access-list outside_access_in extended permit tcp any host 172.20.20.1 +25 eq www access-list outside_access_in extended permit tcp any host 172.20.20.1 +25 eq smtp

  • several lines with a head

  • where there is a space in front of every statement and I have to change again de IP
    interface GigabitEthernet0/1 nameif inside security-level 100 ip address 172.20.0.1 255.255.0.0 ospf network point-to-point non-broadcast

  • several lines with multiple level of indentation

  • where IP address has to change according to the backup site
    username prod_9847776 attributes service-type remote-access webvpn url-list value _10.1.5.20_allow

    Which would be the best way to treat this entries to compare the configuration from one site to the other and get the differences that has to be modified before being applied on the second site?
    I can't just compare two files line by line, I need to compare in a way by block or something I can't get up with now and I kindly ask your enlightenment.

    Comment on Compare and apply differences on configuration file
    Select or Download Code
    Re: Compare and apply differences on configuration file
    by Anonymous Monk on May 06, 2014 at 08:56 UTC
        Thank you, I'll take a look a this module, seems quite what I need and has a very interesting approach by using templates.

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: perlquestion [id://1085150]
    Approved by Corion
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (3)
    As of 2014-10-26 07:52 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (152 votes), past polls