NetReplica Criando Templates
CLAB Template Structure
CLAB templates follow a specific structure, which allows NetReplica to interpret and apply the configurations correctly. Here is an example of a CLAB template for a ceos device:
{{ name }}:
kind: ceos
image: ceos:latest
{% if configuration_file is defined %}
startup-config: {{ configuration_file }}
{% endif %}
{% if interface_map is defined %}
binds:
- {{ interface_map }}:/mnt/flash/EosIntfMapping.json:ro
{% endif %}
{% include 'clab/labels.j2' %}
In this example:
{{ name }}is a variable that will be replaced by the device name.kinddefines the type of device, in this case, "ceos".imagespecifies the device image.startup-configallows you to define an initial configuration file.bindsallows you to map volumes, such as interface mapping.includeis used to include additional labels from the CLAB template.
Creating CLAB Templates
To create your own CLAB templates, follow the example structure and format provided. You can create .j2 files, remembering that the filename should be the platform name for each device type, and customize the configurations as needed. Save your templates in the templates/clab/kinds/ directory of your NetReplica environment.
By creating and using CLAB templates, you have the flexibility to define how devices will be provisioned and configured within the CLAB environment, allowing for precise replication of your network.
Example of the junos template junos.j2
{{ name }}:
kind: crpd
image: crpd:23.1R1.8
{% if configuration_file is defined %}
startup-config: {{ configuration_file }}
{% endif %}
{% if interface_map is defined %}
binds:
- {{ interface_map }}:/mnt/flash/EosIntfMapping.json:ro
{% endif %}
{% include 'clab/labels.j2' %}
Step 2: Running NetReplica with the Configuration File
Once you have created and configured the .conf file with the desired options, you are ready to run NetReplica and start replicating and analyzing networks based on the NetBox information. Follow the steps below to run NetReplica:
- Configuration File Location: Make sure the
.conffile is in the correct location. If you are using NetReplica via Docker, remember that the.conffile must be inside the "conf" directory that is created after running the compose. - Starting NetReplica: Open a terminal or command prompt and navigate to the directory where NetReplica is installed. If you are using NetReplica via Docker, make sure you are in the directory where the
docker-compose.ymlfile is located. -
Running NetReplica: Execute the command to start NetReplica, passing the path to the
.conffile as an argument. For example, if the.conffile is in the current directory and is namednetreplica.conf, the command might be:nrx -c <file>.conf
If you are using NetReplica via Docker, the command to run might be:
```bash
docker exec -it nrx ./nrx -c conf/<file>.conf
```
- Monitoring Execution: During execution, NetReplica will use the settings from the
.conffile to access NetBox and start the network replication and analysis. Monitor the terminal output to see the progress and any relevant messages. - Execution Results: After the execution is complete, the replication and analysis results will be available in the output directory specified in the
.conffile (usually theOUTPUT_DIRdirectory). You will be able to find the exported files, such as images, device configurations, and other data, according to the defined settings.
Remember that NetReplica is a powerful tool for replicating and analyzing networks based on NetBox information. By running NetReplica with the correctly configured configuration file, you will be exploring the integration capabilities between these two tools to gain valuable insights into your network.
Sources
- NetReplica (NRX) GitHub Repository. Available at: https://github.com/netreplica/nrx
- NetReplica Templates GitHub Repository. Available at: https://github.com/netreplica/templates
- ContainerLab Manual - Kinds. Available at: https://containerlab.dev/manual/kinds/