Skip to content

Support NetBox v3 #22

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 3 commits 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
16 changes: 15 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#
# Configures Netbox and gunicorn, and load the database schema.
#
# @param version
# The version of Netbox. This must match the version in the
# tarball. This is used for managing files, directories and paths in
# the service.
#
# @param user
# The user owning the Netbox installation files, and running the
# service.
Expand Down Expand Up @@ -135,6 +140,7 @@
# @example
# include netbox::config
class netbox::config (
String $version,
String $user,
String $group,
Stdlib::Absolutepath $install_root,
Expand Down Expand Up @@ -195,6 +201,7 @@

file { $config_file:
content => epp('netbox/configuration.py.epp', {
'version' => $version,
'allowed_hosts' => $allowed_hosts,
'database_name' => $database_name,
'database_user' => $database_user,
Expand Down Expand Up @@ -248,9 +255,16 @@
require => File[$config_file],
notify => Exec['collect static files'],
}
file { 'static_folder':
ensure => 'directory',
path => "${software_directory}/netbox/static",
owner => $user,
group => $group,
mode => '0644',
}
exec { 'collect static files':
command => "${venv_dir}/bin/python3 netbox/manage.py collectstatic --no-input",
require => File[$config_file],
require => [ File[$config_file], File['static_folder'] ],
refreshonly => true,
}
}
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
}

class { 'netbox::config':
version => $version,
user => $user,
group => $group,
install_root => $install_root,
Expand Down
4 changes: 2 additions & 2 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@

$packages =[
gcc,
python36,
python36-devel,
python39,
python39-devel,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most distros don't have packages named python39 or python39-devel, at least not available in their main repos. The only match I could find is in CentOS 8 AppStream. It would be best if these could be overridden. For example, in CentOS 7, the SCL package is named rh-python38-python.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module supports CentOS and RedHat 8 only... So I bump this version to match with NetBox v3 requirements (with main repositories of these distros). If you want to make this module compatible with CentOS 7, indeed you must have as a prerequisite the SCL repository and specify the version 3.8. I don't think so this feature should be in this PR...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I filed #24

libxml2-devel,
libxslt-devel,
libffi-devel,
Expand Down
3 changes: 3 additions & 0 deletions templates/configuration.py.epp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% |
String $version,
Array[Stdlib::Host] $allowed_hosts,
String $database_name,
String $database_user,
Expand Down Expand Up @@ -115,8 +116,10 @@ BANNER_LOGIN = '<%= $banner_login %>'
# BASE_PATH = 'netbox/'
BASE_PATH = '<%= $base_path %>'

<% if versioncmp(split($version, '[.]')[0], '3') < 0 { -%>
# Cache timeout in seconds. Set to 0 to dissable caching. Defaults to 900 (15 minutes)
CACHE_TIMEOUT = 900
<% } -%>

# Maximum number of days to retain logged changes. Set to 0 to retain changes indefinitely. (Default: 90)
CHANGELOG_RETENTION = 90
Expand Down