Configuration Parsers
  • 05 Dec 2024
  • Dark
    Light
  • PDF

Configuration Parsers

  • Dark
    Light
  • PDF

Article summary

The Golden Configurations view of Configuration Manager allows you to perform configuration updates and compliance checks against one or many devices. To perform these operations, Golden Configurations needs a set of rules it can use to interpret the configuration data it is provided. Configuration parsers provide the definitions and logic that Golden Configurations uses when it is processing a configuration.

Configuration parsers are managed from the Configuration Parsers view of Configuration Manager, from which you can:

  • View and edit the rules of configuration parsers.
  • Test configuration parsers.
  • Create custom configuration parsers.
  • Edit configuration parser metadata.

This page documents the features of the Configuration Parsers view and provides guidance on how to perform common tasks within it.

Opening an Existing Configuration Parser

To open an existing configuration parser from the Configuration Manager homepage:

  1. Select the Configuration Parsers header in the side navigation panel to open an accordion menu that displays a list of existing configuration parsers (Figure 1).
  2. Select a configuration parser from the list to open it in the Configuration Parsers view.
ⓘ Note:

You can use the Search bar at the top of the accordion menu to filter the list of configuration parsers by name. Alternatively, you can search for configuration parsers using the Collections view of Configuration Manager by selecting the Search (magnifying glass) icon from the side navigation panel toolbar.


Figure 1: Opening an Existing Configuration Parser

Opening an Existing Configuration Parser


Configuration Parsers UI

Immediately after selecting a configuration parser, you will be redirected to the Configuration Parsers view (Figure 2). The user interface (UI) elements of the Configuration Parsers view are referenced in the table below.

Label UI Element Function
1 Menu Button Displays a list of configuration parser management actions, such as viewing metadata and deleting the current configuration parser.
2 Parser Rule Editor Allows you to view and edit parser rules.
3 Parser Data Editor Allows you to provide an example configuration to run the configuration parser against.
4 Parser Execution Log Displays the results of running the configuration parser against a provided example configuration.

Figure 2: Configuration Parsers UI

Configuration Parsers UI


Parser Rules

The logic a configuration parser uses when it is processing a configuration is determined by a set of parser rules. Parser rules can be viewed and edited from the Parser Rule Editor.

Parser Rule Syntax

Parser rules are listed within a single parent array. Within this parent array, each individual parser rule is specified as a two-value child array (Figure 3).

Figure 3: Annotation of Cisco IOS Parser Rules

Annotation of Cisco IOS Parser Rules


The first value in a parser rule is a regular expression. When a configuration parser is processing a configuration, it will attempt to match each part of the configuration to a parser rule by using this regular expression. If a match is made, that part of the configuration is assigned the keyword listed in the second value of the parser rule. The assigned keyword prescribes how Golden Configurations should interact with that part of the configuration.

Caution

Parser rules are listed in a descending order of precedence. If part of a configuration can be matched to multiple parser rules, the parser rule that appears closest to the beginning of the array will be used.


Parser Rule Master Templates

All configuration parsers are based on a Master Template, either the Cisco-IOS Master Template or the F5-BigIP Master Template. Master templates define the keywords that a configuration parser can use in its parser rules. The following tables list and describe the keywords made available by each master template.

Cisco-IOS Master Template

Keyword Description
word Identifies a word (example: interface) in a configuration.
whitespace Identifies spacing or any other content in a configuration that should be ignored.
banner Identifies a banner in a configuration. Banners are captured uniformly instead of as separate words.
end_line Identifies the end of a line in a configuration.

F5-BigIP Master Template

Keyword Description
word Identifies a word (example: interface) in a configuration.
quoted_string Identifies a series of words in a configuration that should be captured as one element.
multiline_quote Identifies a series of words spanning multiple lines in a configuration that should be captured as one element.
open_statement_block Defines the entry point of a block scope (e.g., { in F5 configurations).
close_statement_block Defines the exit point of a block scope (e.g., } in F5 configurations).
end_line Identifies the end of a line in a configuration.
statement_terminator Identifies the end of a line or scope in a configuration (e.g., ; in a Junos configuration); similar to end_line.

Example - Parser Rule Operation

The Cisco-IOS configuration parser uses the following parser rule to detect and identify the banner command in Cisco IOS configurations:

[
    "(banner (exec|incoming|login|motd|prompt-timeout|config-save|lcd)\\s+\\^C[\\s\\S]*?(\\^C))",
    "banner"
],

As the configuration parser is processing a configuration, it encounters the following data:

banner login ^C
This is the first line of an example banner.
This is the second line of an example banner.
^C

The configuration parser matches this data to the banner parser rule using the regular expression defined in the rule. The data is then assigned the keyword listed in the rule, banner, which allows Golden Configurations to treat the data as an instance of the banner command.


Testing Configuration Parsers

After parser rules have been defined for a configuration parser, you can test the configuration parser by running it against an example configuration.

To test a configuration parser from the Configuration Parsers view:

  1. Enter an example configuration into the Parser Data Editor. This can be done by:

    • Typing or pasting the example configuration into the Parser Data Editor.
    • Importing a configuration from an available device. To do this, hover over the Select Device button in the Parser Data Editor toolbar and select the relevant device from the list that appears.

    Figure 4: Importing a Device Configuration
    Importing a Device Configuration

  2. Click the Execute (►) button in the Parser Rule Editor toolbar.

  3. Review the output in the Parser Execution Log. Output will be color-coded to identify which parser rule each part of the configuration was matched to.


Example - Testing the Cisco-IOS Configuration Parser

The following Cisco IOS configuration has been processed by the Cisco-IOS configuration parser:

banner login ^C
This is line one of a banner.
This is line two of a banner.
^C
ip domain-lookup
ip domain-name example.dns.io
ip name-server 10.0.0.254
ntp server 10.0.0.253 use-vrf default

The output displayed in the Parser Execution Log reports that lines 1-4 of the configuration were matched to the banner parser rule. As such, lines 1-4 were assigned the keyword specified in the rule, banner. The rest of the configuration has been matched to the last occurring word parser rule and assigned the keyword specified in that rule, word.

Figure 5: Processed Cisco IOS Configuration

Processed Cisco IOS Configuration


Creating Custom Configuration Parsers

Configuration Manager includes many pre-made configuration parsers tailored to common network operating systems. However, to manage a device that uses a configuration syntax not supported by a pre-made configuration parser, you will need to create a custom configuration parser.

To create a custom configuration parser from the Configuration Manager homepage:

  1. Click the Create (+) button from the side navigation panel toolbar to open the Create modal.
  2. Select Configuration Parser from the dropdown menu.
  3. Enter a name for the configuration parser.
  4. Select an existing configuration parser to use as a template for the new configuration parser.
  5. Click the Create button.

Immediately after creating a configuration parser, you will be redirected to the Configuration Parsers view. From here, you can use the Parser Rule Editor to construct parser rules that match the configuration syntax of your device.

Example - Creating a Custom Cisco NX Configuration Parser

A Cisco NX device that uses a banner command in its configuration needs to be managed via Golden Configurations. Though Configuration Manager includes a pre-made Cisco NX configuration parser, it does not have any parser rules that identify an instance of the banner command. In this instance, a custom configuration parser is needed.

A custom configuration parser, named Cisco-NX-Example, has been created based on the existing cisco-nx configuration parser. Upon creation, the custom configuration parser contains the same parser rules as the template configuration parser:

[
  [
    "(\\r\\n|\\r|\\n)",
    "end_line"
  ],
  [
    "$",
    "end_line"
  ],
  [
    "\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"",
    "word"
  ],
  [
    "\\S+",
    "word"
  ]
]

In Cisco NX configurations, the @ character is used to open and close the banner command. To recognize this pattern, the following parser rule is added to the top of the parent parser rule array:

[
  "(banner (exec|incoming|login|motd|prompt-timeout|config-save|lcd)\\s+@[\\s\\S]*?(@))",
  "banner"
],

The following configuration is then provided to the configuration parser:

banner login @
This is the first line of an example banner.
This is the second line of an example banner.
@
ip domain-lookup
ip domain-name example.dns.io
ip name-server 10.0.0.2

The output displayed in the Parser Execution Log reports that lines 1-4 of the configuration were matched to the banner parser rule. As such, lines 1-4 were assigned the keyword specified in the rule, banner. The rest of the configuration has been matched to the last occurring word parser rule and assigned the keyword specified in that rule, word.


Figure 6: Processed Cisco NX Configuration

Processed Cisco NX Configuration


To use the custom configuration parser in Golden Configurations, the parser name (Cisco-NX-Example) is selected as the OS Type when creating a new Golden Configuration.

Figure 7: Creating a Golden Configuration

Creating a Golden Configuration


Editing Configuration Parser Metadata

Configuration parsers have several metadata values, including:

  • The name of the configuration parser.
  • The creation date of the configuration parser.
  • User groups that have been granted access to the configuration parser.
  • Optionally, the specific operating system (OS) types that the configuration parser supports.

To view and edit the metadata values of a configuration parser from the Configuration Parsers view:

  1. Click the menu (⋮) button located at the upper-right corner of the window.
  2. Select View Metadata from the menu to display the metadata panel at the top of the window.
  3. Enter any changes into the relevant text input fields.
  4. Click the Save button at the bottom-left corner of the metadata panel.

Figure 8: Metadata Panel

Metadata Panel


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.