Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Compare and apply differences on configuration file

by cord-bin (Friar)
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 became
    access-list outside_access_in extended permit tcp any host +25 eq www access-list outside_access_in extended permit tcp any host +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 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.

    Replies are listed 'Best First'.
    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?

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: perlquestion [id://1085150]
    Approved by Corion
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (4)
    As of 2018-05-26 20:26 GMT
    Find Nodes?
      Voting Booth?