Tutorial 6 - Config Maker - Flexible ConfigMaker

The Flexible configmaker is used to generate configs, where the number of some elements may vary between the generated files - i.e. object-groups in firewall configs - it could be that object-group local-servers has one entry at site A and 10 entries at site B.
This Tutorial will provide a step-by-step guidance on how to use this feature.

Overview:
The goal of this tutorial is to get three object-groups (OG). Each OG is for a single firewall and the number of entries vary. The first OG should have three entries, the second one has 10 entries and the third one has 23 entries. Since wktools uses only one line of the data file to generate a single config file, the variable entries for the object groups must be inserted in one cell (in Excel).

Download the used files here.


Step 1 - Create a pattern file:

The pattern file contains the configuration with placeholders for the variable data. "$" is used as placeholder identifier. This example also uses tags which have two leading "$" signs.

Example:

config.txt:
 
    object-group $ogname
     $$b network-object $obj $$n $$e $$i
 


The string between $$b and $$e is copied n times. The number is specified in the $$i tag. $$n inserts a line break. When $$i is 3 and the output is generated, the object group will contain three "network-object $obj" lines. All tags are deleted in the output.
Note: There are two replacement cycles needed. In the first cycle, all tags are replaced and the string is copied AND "$obj" is replaced by "$ip $mask". In the second cycle "$ip $mask" is replaced by the proper values. This is needed, because if $ip and $mask would be used in the first cycle, the two placeholder would be replaced by the proper values, and the vlaues, and not the placeholders would be copied i times.


Step 2 - Create the Data File:

The Data file contains the information which should be filled into the pattern file.
In this case the data file is not straight forward, because each cell (in Excel) can contain more than one data entry. This is done by using Linebreaks within these cells (ATL+ENTER). When saving the xls as csv, these Line Breaks are saved as LF.

Example (only the first part is shown):

data.csv: 
$ogname;$obj;$$b;$$e;$$n;$$i;$ip;$mask
 og1;$ip $mask;;;;3;"10.1.1.1
 10.1.1.2
 10.1.1.3";"255.255.255.255
 255.255.255.255
 255.255.255.255"
 og2;$ip $mask;;;;5;"192.168.1.1
 192.168.1.2
 192.168.1.3
 192.168.1.4
 192.168.1.5";"255.255.255.255
 255.255.255.255
 255.255.255.255
 255.255.255.255
 255.255.255.255"
 og3;$ip $mask;;;;23;"192.168.1.1
 192.168.1.2
 ....


Please use the provided files to get an idea how the xls looks like. You do not need to set a value for the tags, except $$i, which is the number, how often the defined string should be copied.


Step 3 - Choose your Options

In the example we use "$ogname" for Filename Variable and "One file per line".




Step 4 - Start

Press Start Button to begin the process.




Step 5 - Result

A log can be found in the Output Tab. In our case it would look like the following:




The three output files are the following:

object-group og1
 network-object 10.1.1.1 255.255.255.255
 network-object 10.1.1.2 255.255.255.255
 network-object 10.1.1.3 255.255.255.255

-----------------------------------------------------

object-group og2
 network-object 192.168.1.1 255.255.255.255
 network-object 192.168.1.2 255.255.255.255
 network-object 192.168.1.3 255.255.255.255
 network-object 192.168.1.4 255.255.255.255
 network-object 192.168.1.5 255.255.255.255


-----------------------------------------------------

object-group og3
 network-object 192.168.1.1 255.255.255.255
 network-object 192.168.1.2 255.255.255.255
 network-object 192.168.1.3 255.255.255.255
 network-object 192.168.1.4 255.255.255.255
 network-object 192.168.1.5 255.255.255.255
 network-object 192.168.1.1 255.255.255.255
 network-object 192.168.1.2 255.255.255.255
 network-object 192.168.1.3 255.255.255.255
 network-object 192.168.1.4 255.255.255.255
 network-object 192.168.1.5 255.255.255.255
 network-object 192.168.1.1 255.255.255.255
 network-object 192.168.1.2 255.255.255.255
 network-object 192.168.1.3 255.255.255.255
 network-object 192.168.1.4 255.255.255.255
 network-object 192.168.1.5 255.255.255.255
 network-object DummyVariable DummyVariable
 network-object DummyVariable DummyVariable
 network-object DummyVariable DummyVariable
 network-object DummyVariable DummyVariable
 network-object DummyVariable DummyVariable
 network-object DummyVariable DummyVariable
 network-object DummyVariable DummyVariable
 network-object DummyVariable DummyVariable