Hi, my first post, so have mercy please ;-) Goal: compare the configuration template (I call it MASK) against actual device configurations to detect anomalies. Here's a sample device config:
============== mpls ldp router-id 192.168.130.5 nsr graceful-restart backoff 5 10 session protection neighbor 192.168.130.1 password encrypted pwd1 neighbor 192.168.130.2 password encrypted pwd2 neighbor 192.168.130.25 password encrypted pwd3 igp sync delay 10 label allocate for LLAF ! log neighbor nsr ! interface TenGigE0/0/0/0 ! interface TenGigE0/1/0/0 ! interface TenGigE0/7/0/0 ! ! ==============
And now my template/MASK:
====================================================================== =|MASK|mpls ldp|= ====================================================================== (mpls ldp) (router-id) (__REGEX__) nsr graceful-restart backoff 5 10 session protection (neighbor) (__REGEX__) password encrypted __REGEX__ (neighbor) (__REGEX__) password encrypted __REGEX__ (neighbor) (__REGEX__) password encrypted __REGEX__ igp sync delay 10 label allocate for LLAF ! log neighbor nsr ! interface (__REGEX__) ! interface (__REGEX__) ! ! ======================================================================
So I read all device config in a string and match with /..../s against template above; before actual match the template updated with $mask_tmp =~ s/__REGEX__/^\\n+/g; Easy part is to match the template against the configuration when eg. number of neighbor or interface statements is the same on all devices. But that is not the case, so I'm looking for idea how to match (and capture necessary parameters such as IP numbers of all neighbors) irrespective of number of neighbors/interfaces in actual config. TIA

In reply to Template-based router configuration audit by ccie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.