Skip to content

Commit c642e6d

Browse files
committed
Implement custom configuration blocks
Fixes anderssh#13 Example: ``` class { '::netbox': version => '3.0.0', custom_configuration => [ "SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL = ${openid_url}", "SOCIAL_AUTH_KEYCLOAK_SECRET = 'secret', ] } ```
1 parent 9153301 commit c642e6d

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

manifests/config.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
String $short_time_format,
170170
String $datetime_format,
171171
String $short_datetime_format,
172+
Array[String] $custom_configuration = [],
172173
) {
173174
$should_create_superuser = false;
174175
$software_directory = "${install_root}/netbox"
@@ -226,6 +227,7 @@
226227
'short_time_format' => $short_time_format,
227228
'datetime_format' => $datetime_format,
228229
'short_datetime_format' => $short_datetime_format,
230+
'custom_configuration' => $custom_configuration,
229231
}),
230232
owner => $user,
231233
group => $group,

manifests/init.pp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,30 @@
212212
# Date/time formatting. See the following link for supported formats:
213213
# https://docs.djangoproject.com/en/stable/ref/templates/builtins/#date
214214
#
215+
# @param custom_configuration
216+
# An array of strings containing custom configuration blocks
217+
# Make sure these are valid python
218+
#
215219
# @example Defaults
216220
# class { 'netbox':
217-
# secret_key => $my_secret_variable
221+
# secret_key => $my_secret_variable
218222
# }
219223
#
220224
# @example Downloading from a different repository
221225
# class { 'netbox':
222-
# version => 'x.y.z',
223-
# download_url => 'https://my.local.repo.example.com/netbox/netbox-x.y.z.tar.gz',
224-
# download_checksum => 'abcde...',
226+
# version => 'x.y.z',
227+
# download_url => 'https://my.local.repo.example.com/netbox/netbox-x.y.z.tar.gz',
228+
# download_checksum => 'abcde...',
225229
# }
226230
#
231+
# @example Using custom configuration entries
232+
# class { '::netbox':
233+
# custom_configuration => [
234+
# 'SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL = "https://login.keycloak/auth",
235+
# 'SOCIAL_AUTH_KEYCLOAK_SECRET = "secret",
236+
# ]
237+
# }
238+
227239
class netbox (
228240
String $secret_key,
229241
String $version = '2.10.1',
@@ -277,6 +289,7 @@
277289
String $short_time_format = 'H:i:s',
278290
String $datetime_format = 'N j, Y g:i a',
279291
String $short_datetime_format = 'Y-m-d H:i',
292+
Array[String] $custom_configuration = [],
280293
) {
281294

282295
Class['netbox::install'] -> Class['netbox::config'] ~> Class['netbox::service']
@@ -381,6 +394,7 @@
381394
short_time_format => $short_time_format,
382395
datetime_format => $datetime_format,
383396
short_datetime_format => $short_datetime_format,
397+
custom_configuration => $custom_configuration,
384398
}
385399

386400
class {'netbox::service':

templates/configuration.py.epp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
String $short_time_format,
3131
String $datetime_format,
3232
String $short_datetime_format,
33+
Array[String] $custom_configuration,
3334
| -%>
3435

3536
#########################
@@ -257,3 +258,6 @@ TIME_FORMAT = '<%= $time_format %>'
257258
SHORT_TIME_FORMAT = '<%= $short_time_format %>'
258259
DATETIME_FORMAT = '<%= $datetime_format %>'
259260
SHORT_DATETIME_FORMAT = '<%= $short_datetime_format %>'
261+
<% $custom_configuration.each|String $block| { -%>
262+
<%= $block %>
263+
<% } -%>

0 commit comments

Comments
 (0)