Templates
Templates are configurations that can be used in multiple places.
Use templates by adding a line in radiusd.conf:
$INCLUDE templates.conf
The goal of the templates is to have common configuration located
in this file, and to list only the differences in the individual
sections. This feature is most useful for sections like clients
where many may be defined, and each one has similar repeated
configuration.
Something similar to templates can be done by putting common
configuration into separate files, and using $INCLUDE file…
,
but templates are more flexible, and simpler to understand. It’s also
cheaper for the server, because $INCLUDE
makes a copy of the
configuration for inclusion, whereas templates are simply referenced.
The templates are defined in the templates
section so that
they do not affect the rest of the server configuration. The
actual contents of the templates section are other
configuration sections that would normally go into the main
configuration files.
Within the main server configuration, a section can reference a
template by using $template name
.
One use case would be if there are multiple instances of the sql module for load balancing or failover. These will typically share many common configuration options which can be set in a template and then that template referred to in each instances of the sql module
sql sql01 {
$template sql-common
...
}
sql sql02 {
$template sql-common
...
}
In that case the template sql-common
could be as follows:
sql-common {
acct_table = 'radacct'
acct_table2 = 'radacct'
postauth_table = 'radpostauth'
authcheck_table = 'radcheck'
groupcheck_table = 'radgroupcheck'
authreply_table = 'radreply'
groupreply_table = 'radgroupreply'
usergroup_table = 'radusergroup'
read_groups = yes
pool {
start = 0
min = 1
spare = 1
}
}