ios_config: match confusion

I’m a little confused on the various match clauses in the ‘ios_config’ module. I understand IOS very well. I’m trying to find use cases for the different options here.

Does anyone have any example of when each would be used?

Here are the options:

  • line
  • strict
  • exact
  • none

Here is the definition:

match=line

  • Simple line matching against the running config with respect to context (parents). If the line is in the config, then nothing will be done. If the line isn’t in the config, it will be added

match=none

  • Ignore the running config all together and push the config lines into the device running config

match=strict

  • Strict line matching, for instance an ACL. Ensures the statements are ordered as per the module definition

  • Example

running-config:
permit 1.1.1.1
permit 2.2.2.2
permit 3.3.3.3
permit 4.4.4.4
permit 5.5.5.5

module - passes

permit 1.1.1.1
permit 2.2.2.2
permit 3.3.3.3
permit 4.4.4.4

module - fails (although match=line would pass)
permit 10 1.1.1.1
permit 20 4.4.4.4
permit 30 2.2.2.2
permit 40 3.3.3.3

match=exact

  • Strict line matching with absolute entries, again most common with ACL

  • Example

running-config:
permit 1.1.1.1
permit 2.2.2.2
permit 3.3.3.3
permit 4.4.4.4
permit 5.5.5.5

module - passes
permit 1.1.1.1
permit 2.2.2.2
permit 3.3.3.3
permit 4.4.4.4
permit 5.5.5.5

module - fails (config has 5 total items, module definition expects only 4)
permit 10 1.1.1.1
permit 20 2.2.2.2
permit 30 2.2.2.2
permit 40 4.4.4.4

HTH