Config Templates
A High Level Source of Truth for your Configuration
Config templates are a powerful way of encoding business logic in a clear and concise way so that it can be applied programmatically to the rXg. These are just my notes about some features, for official documentation please see Config Templates
In my opinion, true mastery of config templates comes from combining 3 things.
-
A mastery of how config templates work syntactically 1.1 ERB Expansion 1.2 YAML Ingestion
-
A wide understanding of the vocabulary of what can be configured via config templates, ie all the scaffolds.
-
The ability combine the first 2 within the context of a particular deployment or operational plan
For the teaching I am going to focus primarily on #1 because that is something that can reasonably be learned in one blog post or short teaching session.
A single template could configure everything an rXg needs from layer 1 to layer 7. For example, here are just some things that can be configured by a config template:
rXg Access and Management
- Admins
- Device Option
- Certificate and Certificate Management
- Operator Portals
- Fleet Management
Networking
- Interfaces and Addresses
- Services: DNS/DHCP/RADIUS
Command and Control
- Infrastructure Device Configuration and Credentials
- Trunk Ports and Access Ports
- WLANs
Payment Gateway Configuration
- Merchant Processing
- PMS
Business Logic and Customization
- Usage Plans
- Portal Customization
- Policies
- Bandwidth Queues
- Uplink Control
Config Templates live in System >> Backup
Config templates behave like scripts that execute in two phases.
Phase 1: ERB Expansion
How to Enable ERB Expansion
Phase one is ERB (Embedded RuBy) expansion. Please note that there is an option to disable this phase if desired, see the red arrow in the picture above. Uncheck the ERB option to disable the ERB processing.
How to Use ERB Expansion
During ERB expansion, if enabled, embedded ruby code found within blocks that look like this, will be be executed.
<% #comment %>
<%= #comment %>
The result will be put into the YAML context for phase 2 if the =
is used. Key
points:
-
Code run inside this context has access to everything, in particular the config database.
-
This can create unintended side effects.
-
This is true even when using the non-printing
<% %>
-
Just removing
=
is not a true comment-out because the code still runs, it just does not print. -
To put in a true comment, add # within the
<% %>
, eg<%#= %>
or<%# %>
Other ERB Details
It may be interesting to some operators to note that ERB is used extensively in the rXg's web UI, including most portals.
Phase 2: YAML Ingestion
In phase 2, the resulting YAML output is evaluated by RG Net's YAML processing engine in order to tell the rXg to execute code. In general these operations are CRUD actions taken against specific records and models. (Well more like just CUD since templates are essentially 1-way creates/updates/destroys, there's not much point of executing a template just to read.)
If you want to tell the rXg to delete a record, include the _delete key in the record definition in the YAML template.
In order to know what record to create/read/update based off of a Template, the rXg will try to do a lookup on the record based off of its name or id. If it finds one, it will try to update/delete that record baed on what the template says to do. If it does not find one, it will try to create one.
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDEUJveJ95+2obvuqI/FAOJR3/7GmdK76BvlH55viARFerX7b8RTWLcTDde49P5FCnZP/x68a6OnWDcqj44pXk50/xf3eGTcmuoYh/c6n/yYsKfBiGZB9gMhFD2A8zeF/fb5ZBXHx1v5m5LE6g9XbuzvoYk/BlCOpTR6u3yl+gVPGOU1kimxCaSHPIU1Y+nFKJbKJgTBjgIZHoQZS+4wzYE1o06tYvFPvenz1uRjmoJJHJaSMptf8oDg9EEvw6c0xkpN4/QUm7RytuJkfL76rWhgp9u2Nkb7S5JTvfoRVwUuIAeLzu1QAUXNfs4ChLU1vEo0GmbibKD4U2CUWUv/JvPTFQJkXdI0xsATZBwdFzmpzm2XM3QYYFttPeD3NHJx+iJkIZcpMD21+Sb4pjG6OGibc1BDKvEFLQSU3tR6RmXM5rWALO56/XBb8fbvxJ5NmcxTeb/HE8MkEYJz/gMDQ+F0aoF68SM71BXx4bsFOAuYZAIfTLEZ/ObXr9DlysFFjJv5IWgRPxVbF2QsGa97rWoyxI7sHTcpW1pekrf/DjdUFvYlPpAPIKkmy8qOM3Bk4DbMWNrArtuCIgRNO7qvos+yu7iBZpuIWDqTaUe2olqwTJECzjwV8Q7InUUKyr4y8oh+t6Mi2d8FknM5qAbznhP9h9OHpdFbgIdgAAZR5Fgg+xVXbrP4XiSbrfQwHXu61QMpgsPvt4fsPcauirrGQcGNOoEbf+yGHiV5zBIgUi3fEl8+mVLdVzJ3qLtfmvcu9hwY4NWXcjboHuRiMjSn4caH3OfFGv7WPT55R8hAleBsQSMgVIobDIoYI8VELS2VW9Cntf8+Le7X+VgOL6No8E18ug33m3PL1gnB/3K+oofsOSsWraT1/5mlyn3qU26Us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