Skip to content

Implement custom configuration blocks #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
String $short_time_format,
String $datetime_format,
String $short_datetime_format,
Array[String] $custom_configuration = [],
) {
$should_create_superuser = false;
$software_directory = "${install_root}/netbox"
Expand Down Expand Up @@ -226,6 +227,7 @@
'short_time_format' => $short_time_format,
'datetime_format' => $datetime_format,
'short_datetime_format' => $short_datetime_format,
'custom_configuration' => $custom_configuration,
}),
owner => $user,
group => $group,
Expand Down
22 changes: 18 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,30 @@
# Date/time formatting. See the following link for supported formats:
# https://docs.djangoproject.com/en/stable/ref/templates/builtins/#date
#
# @param custom_configuration
# An array of strings containing custom configuration blocks
# Make sure these are valid python
#
# @example Defaults
# class { 'netbox':
# secret_key => $my_secret_variable
# secret_key => $my_secret_variable
# }
#
# @example Downloading from a different repository
# class { 'netbox':
# version => 'x.y.z',
# download_url => 'https://my.local.repo.example.com/netbox/netbox-x.y.z.tar.gz',
# download_checksum => 'abcde...',
# version => 'x.y.z',
# download_url => 'https://my.local.repo.example.com/netbox/netbox-x.y.z.tar.gz',
# download_checksum => 'abcde...',
# }
#
# @example Using custom configuration entries
# class { '::netbox':
# custom_configuration => [
# 'SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL = "https://login.keycloak/auth",
# 'SOCIAL_AUTH_KEYCLOAK_SECRET = "secret",
# ]
# }

class netbox (
String $secret_key,
String $version = '2.10.1',
Expand Down Expand Up @@ -277,6 +289,7 @@
String $short_time_format = 'H:i:s',
String $datetime_format = 'N j, Y g:i a',
String $short_datetime_format = 'Y-m-d H:i',
Array[String] $custom_configuration = [],
) {

Class['netbox::install'] -> Class['netbox::config'] ~> Class['netbox::service']
Expand Down Expand Up @@ -381,6 +394,7 @@
short_time_format => $short_time_format,
datetime_format => $datetime_format,
short_datetime_format => $short_datetime_format,
custom_configuration => $custom_configuration,
}

class {'netbox::service':
Expand Down
4 changes: 4 additions & 0 deletions templates/configuration.py.epp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
String $short_time_format,
String $datetime_format,
String $short_datetime_format,
Array[String] $custom_configuration,
| -%>

#########################
Expand Down Expand Up @@ -257,3 +258,6 @@ TIME_FORMAT = '<%= $time_format %>'
SHORT_TIME_FORMAT = '<%= $short_time_format %>'
DATETIME_FORMAT = '<%= $datetime_format %>'
SHORT_DATETIME_FORMAT = '<%= $short_datetime_format %>'
<% $custom_configuration.each|String $block| { -%>
<%= $block %>
<% } -%>