Puppet Class: netbox

Defined in:
manifests/init.pp

Summary

Manage Netbox

Overview

Install, configure and run Netbox

Examples:

Defaults

class { 'netbox':
  secret_key => $my_secret_variable
}

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...',
}

Parameters:

  • version (String) (defaults to: '2.10.1')

    The version of Netbox. This must match the version in the tarball. This is used for managing files, directories and paths in the service.

  • user (String) (defaults to: 'netbox')

    The user owning the Netbox installation files, and running the service.

  • group (String) (defaults to: 'netbox')

    The group owning the Netbox installation files, and running the service.

  • secret_key (String)

    A random string of letters, numbers and symbols that Netbox needs. This needs to be supplied, and should be treated as a secret. Should be at least 50 characters long.

  • download_url (String) (defaults to: 'https://github.com/netbox-community/netbox/archive/v2.10.1.tar.gz')

    Where to download the binary installation tarball from.

  • download_checksum (String) (defaults to: 'b827c520e4c82842e426a5f9ad2d914d1728a3671e304d5f25eb06392c24866c')

    The expected checksum of the downloaded tarball. This is used for verifying the integrity of the downloaded tarball.

  • download_checksum_type (String) (defaults to: 'sha256')

    The checksum type of the downloaded tarball. This is used for verifying the integrity of the downloaded tarball.

  • download_tmp_dir (Stdlib::Absolutepath) (defaults to: '/var/tmp')

    Temporary directory for downloading the tarball.

  • install_root (Stdlib::Absolutepath) (defaults to: '/opt')

    The directory where the netbox installation is unpacked

  • handle_database (Boolean) (defaults to: true)

    Should the PostgreSQL database be handled by this module.

  • include_napalm (Boolean) (defaults to: true)

    NAPALM allows NetBox to fetch live data from devices and return it to a requester via its REST API. Installation of NAPALM is optional. To enable it, set $include_napalm to true

  • include_django_storages (Boolean) (defaults to: true)

    By default, NetBox will use the local filesystem to storage uploaded files. To use a remote filesystem, install the django-storages library and configure your desired backend in configuration.py.

  • include_ldap (Boolean) (defaults to: true)

    Makes sure the packages and the python modules needed for LDAP-authentication are installed and loaded. The LDAP-config itself is not handled by this Puppet module at present. Use the documentation found here: netbox.readthedocs.io/en/stable/installation/5-ldap/ for information about the config file.

  • email_server (String) (defaults to: 'localhost')

    Host name or IP address of the email server (use localhost if running locally) netbox.readthedocs.io/en/stable/configuration/optional-settings/#email

  • email_timeout (Integer) (defaults to: 10)

    Amount of time to wait for a connection (seconds) netbox.readthedocs.io/en/stable/configuration/optional-settings/#email

  • email_port (Stdlib::Port) (defaults to: 25)

    TCP port to use for the connection (default: 25) netbox.readthedocs.io/en/stable/configuration/optional-settings/#email

  • email_username (String) (defaults to: '')
  • email_password (String) (defaults to: '')
  • email_from_email (String) (defaults to: '')
  • handle_redis (Boolean) (defaults to: true)

    Should the Redis installation be handled by this module. Defaults to true.

  • install_dependencies_from_filesystem (Boolean) (defaults to: false)

    Used if your machine can’t reach the place pip would normally go to fetch dependencies as it would when running “pip install -r requirements.txt”. Then you would have to fetch those dependencies beforehand and put them somewhere your machine can reach. This can be done by running (on a machine that can reach pip’s normal sources) the following: pip download -r <requirements.txt> -d <destination> Remember to do this on local_requirements.txt also if you have one.

  • python_dependency_path (Stdlib::Absolutepath) (defaults to: '/srv/python_dependencies')

    Path to where pip can find packages when the variable $install_dependencies_from_filesystem is true

  • database_name (String) (defaults to: 'netbox')

    Name of the PostgreSQL database. If handle_database is true, then this database gets created as well. If not, then it is only used by the application, and needs to exist. Defaults to ‘netbox’

  • database_user (String) (defaults to: 'netbox')

    Name of the PostgreSQL database user. If handle_database is true, then this database user gets created as well. If not, then it is only used by the application, and needs to exist. Defaults to ‘netbox’

  • database_password (String) (defaults to: 'netbox')

    Name of the PostgreSQL database password. If handle_database is true, then this database password gets created as well. If not, then it is only used by the application, and needs to exist. Defaults to ‘netbox’

  • database_encoding (String) (defaults to: 'UTF-8')

    Encoding of the PostgreSQL database. If handle_database is false, this does nothing. Defaults to ‘UTF-8’

  • database_locale (String) (defaults to: 'en_US.UTF-8')

    Locale of the PostgreSQL database. If handle_database is false, this does nothing. Defaults to ‘en_US.UTF-8”

  • database_host (Stdlib::Host) (defaults to: 'localhost')

    Name of the PostgreSQL database host. Defaults to ‘localhost’

  • database_port (Integer) (defaults to: 5432)

    PostgreSQL database port. NB! The PostgreSQL database that is made when using handle_database does not support configuring a non-standard port. So change this parameter only if using separate PostgreSQL DB with non-standard port. Defaults to 5432.

  • database_conn_max_age (Integer) (defaults to: 300)

    Database max connection age in seconds. Defaults to 300.

  • allowed_hosts (Array[Stdlib::Host]) (defaults to: ['netbox.exmple.com','localhost'])

    Array of valid fully-qualified domain names (FQDNs) for the NetBox server. NetBox will not permit write access to the server via any other hostnames. The first FQDN in the list will be treated as the preferred name.

  • banner_top (String) (defaults to: '')

    Text for top banner on the Netbox webapp Defaults to the empty string

  • banner_bottom (String) (defaults to: '')

    Text for bottom banner on the Netbox webapp Defaults to the empty string

  • banner_login (String) (defaults to: '')

    Text for login banner on the Netbox webapp Defaults to the empty string

  • base_path (String) (defaults to: '')

    Base URL path if accessing NetBox within a directory. For example, if installed at example.com/netbox/, set: BASE_PATH = ‘netbox/’

  • admins (Array) (defaults to: [])

    Array of hashes with two keys, ‘name’ and ‘email’. This is where the email goes if something goes wrong This feature (in the Puppet module) is not well tested.

  • debug (Boolean) (defaults to: false)

    Set to True to enable server debugging. WARNING: Debugging introduces a substantial performance penalty and may reveal sensitive information about your installation. Only enable debugging while performing testing. Never enable debugging on a production system.

  • login_required (Boolean) (defaults to: false)

    Setting this to True will permit only authenticated users to access any part of NetBox. By default, anonymous users are permitted to access most data in NetBox (excluding secrets) but not make any changes.

  • metrics_enabled (Boolean) (defaults to: false)

    Setting this to true exposes Prometheus metrics at /metrics. See the Promethues Metrics documentation for more details: netbox.readthedocs.io/en/stable/additional-features/prometheus-metrics/)

  • enforce_global_unique (Boolean) (defaults to: false)

    Enforcement of unique IP space can be toggled on a per-VRF basis. To enforce unique IP space within the global table (all prefixes and IP addresses not assigned to a VRF), set ENFORCE_GLOBAL_UNIQUE to True.

  • prefer_ipv4 (Boolean) (defaults to: false)

    When determining the primary IP address for a device, IPv6 is preferred over IPv4 by default. Set this to True to prefer IPv4 instead.

  • exempt_view_permissions (Array) (defaults to: [])

    Exempt certain models from the enforcement of view permissions. Models listed here will be viewable by all users and by anonymous users. List models in the form ‘<app>.<model>`. Add ’*‘ to this list to exempt all models.

  • napalm_username (String) (defaults to: '')

    Username that NetBox will uses to authenticate to devices when connecting via NAPALM.

  • napalm_password (String) (defaults to: '')

    Password that NetBox will uses to authenticate to devices when connecting via NAPALM.

  • napalm_timeout (Integer) (defaults to: 30)

    NAPALM timeout (in seconds).

  • time_zone (String) (defaults to: 'UTC')

    Time zone

  • date_format (String) (defaults to: 'N j, Y')

    Date/time formatting. See the following link for supported formats: docs.djangoproject.com/en/stable/ref/templates/builtins/#date

  • short_date_format (String) (defaults to: 'Y-m-d')

    Date/time formatting. See the following link for supported formats: docs.djangoproject.com/en/stable/ref/templates/builtins/#date

  • time_format (String) (defaults to: 'g:i a')

    Date/time formatting. See the following link for supported formats: docs.djangoproject.com/en/stable/ref/templates/builtins/#date

  • short_time_format (String) (defaults to: 'H:i:s')

    Date/time formatting. See the following link for supported formats: docs.djangoproject.com/en/stable/ref/templates/builtins/#date

  • datetime_format (String) (defaults to: 'N j, Y g:i a')

    Date/time formatting. See the following link for supported formats: docs.djangoproject.com/en/stable/ref/templates/builtins/#date

  • short_datetime_format (String) (defaults to: 'Y-m-d H:i')

    Date/time formatting. See the following link for supported formats: docs.djangoproject.com/en/stable/ref/templates/builtins/#date



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'manifests/init.pp', line 227

class netbox (
  String $secret_key,
  String $version = '2.10.1',
  String $download_url = 'https://github.com/netbox-community/netbox/archive/v2.10.1.tar.gz',
  String $download_checksum = 'b827c520e4c82842e426a5f9ad2d914d1728a3671e304d5f25eb06392c24866c',
  Stdlib::Absolutepath $download_tmp_dir = '/var/tmp',
  String $user = 'netbox',
  String $group = 'netbox',
  String $download_checksum_type = 'sha256',
  Stdlib::Absolutepath $install_root = '/opt',
  Boolean $handle_database = true,
  Boolean $handle_redis = true,
  Boolean $install_dependencies_from_filesystem = false,
  Stdlib::Absolutepath $python_dependency_path = '/srv/python_dependencies',
  Boolean $include_napalm = true,
  Boolean $include_django_storages = true,
  Boolean $include_ldap = true,
  String $database_name       = 'netbox',
  String $database_user       = 'netbox',
  String $database_password   = 'netbox',
  String $database_encoding   = 'UTF-8',
  String $database_locale     = 'en_US.UTF-8',
  Stdlib::Host $database_host = 'localhost',
  Integer $database_port = 5432,
  Integer $database_conn_max_age = 300,
  Array[Stdlib::Host] $allowed_hosts = ['netbox.exmple.com','localhost'],
  String $banner_top = '',
  String $banner_bottom = '',
  String $banner_login = '',
  String $base_path ='',
  Array $admins = [],
  Boolean $debug = false,
  Boolean $enforce_global_unique = false,
  Boolean $login_required = false,
  Boolean $metrics_enabled = false,
  Boolean $prefer_ipv4 = false,
  Array $exempt_view_permissions = [],
  String $napalm_username = '',
  String $napalm_password = '',
  Integer $napalm_timeout = 30,
  String $email_server = 'localhost',
  Integer $email_timeout = 10,
  Stdlib::Port $email_port = 25,
  String $email_username = '',
  String $email_password = '',
  String $email_from_email = '',
  String $time_zone = 'UTC',
  String $date_format = 'N j, Y',
  String $short_date_format = 'Y-m-d',
  String $time_format = 'g:i a',
  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',
) {

  Class['netbox::install'] -> Class['netbox::config'] ~> Class['netbox::service']

  if $handle_database {
    class { 'netbox::database':
      database_name     => $database_name,
      database_user     => $database_user,
      database_password => $database_password,
      database_encoding => $database_encoding,
      database_locale   => $database_locale,
    }
    if $handle_redis {
      Class['netbox::database'] -> Class['netbox::redis']
    } else {
      Class['netbox::database'] -> Class['netbox::install']
    }
  }

  if $handle_redis {
    class { 'netbox::redis':
    }
    Class['netbox::redis'] -> Class['netbox::install']
  }

  class { 'netbox::install':
    install_root                         => $install_root,
    version                              => $version,
    user                                 => $user,
    group                                => $group,
    download_url                         => $download_url,
    download_checksum                    => $download_checksum,
    download_checksum_type               => $download_checksum_type,
    download_tmp_dir                     => $download_tmp_dir,
    include_napalm                       => $include_napalm,
    include_django_storages              => $include_django_storages,
    include_ldap                         => $include_ldap,
    install_dependencies_from_filesystem => $install_dependencies_from_filesystem,
    python_dependency_path               => $python_dependency_path,
  }

  $redis_options = {
    'tasks' => {
      host => 'localhost',
      port => 6379,
      password => '',
      database => 0,
      default_timeout => 300,
      ssl => 'False',
    },
    'caching' => {
      host => 'localhost',
      port => 6379,
      password => '',
      database => 1,
      default_timeout => 300,
      ssl => 'False',
    },
  }

  $email_options = {
    server     => $email_server,
    port       => $email_port,
    username   => $email_username,
    password   => $email_password,
    timeout    => $email_timeout,
    from_email => $email_from_email,
  }

  class { 'netbox::config':
    user                    => $user,
    group                   => $group,
    install_root            => $install_root,
    allowed_hosts           => $allowed_hosts,
    database_name           => $database_name,
    database_user           => $database_user,
    database_password       => $database_password,
    database_host           => $database_host,
    database_port           => $database_port,
    database_conn_max_age   => $database_conn_max_age,
    redis_options           => $redis_options,
    email_options           => $email_options,
    secret_key              => $secret_key,
    admins                  => $admins,
    banner_top              => $banner_top,
    banner_bottom           => $banner_bottom,
    banner_login            => $banner_login,
    base_path               => $base_path,
    debug                   => $debug,
    enforce_global_unique   => $enforce_global_unique,
    login_required          => $login_required,
    metrics_enabled         => $metrics_enabled,
    prefer_ipv4             => $prefer_ipv4,
    exempt_view_permissions => $exempt_view_permissions,
    napalm_username         => $napalm_username,
    napalm_password         => $napalm_password,
    napalm_timeout          => $napalm_timeout,
    time_zone               => $time_zone,
    date_format             => $date_format,
    short_date_format       => $short_date_format,
    time_format             => $time_format,
    short_time_format       => $short_time_format,
    datetime_format         => $datetime_format,
    short_datetime_format   => $short_datetime_format,
  }

  class {'netbox::service':
    install_root => $install_root,
    user         => $user,
    group        => $group,
  }
}