How to install Netbox
NetBox is an open source web application the is design to manage a network infrastructure.
In this tutorial, we will be installing Netbox using puppet for the installation and a bash script for the basic configuration.
Prerequisites
For this turtorail, we will need:
- A puppet master node (puppet version 4.10)
- The netbox node (Debian 9 Stretch and puppet client vesion 4.8)
- The puppetlabs postgresql module
- The puppetlabs-vcsrepo module
Installation
We will not convert the installation and configuration of puppet master in this tutorial. if you do not have a puppet master server in your environment, you can do all the steps below manually by following the instructions in the reference section. Once done, you can continue with this tutorial from the configuration section.
Download modules
Login to your puppet master node and issue the command below to download the puppetlabs postgresql module
sudo puppet module install puppetlabs-postgresql --version 5.9.0
This will download the postgresql moudle and save it into
/etc/puppetlabs/code/environments/production/modules$
Next we will download the puppetlabs vcsrepo module using the command below
sudo puppet module install puppetlabs-vcsrepo --version 2.3.0
This will download the vcsrepo moudle and save it into
/etc/puppetlabs/code/environments/production/modules$
Create the class
Let us create our netbox_install class that will be used to install Netbox and Posgresql. Under /etc/puppetlabs/code/environments/production/modules/$ create netbox directory
sudo mkdir /etc/puppetlabs/code/environments/production/modules/netbox/$
Then create the manifests director under the netbox directory
sudo mkdir /etc/puppetlabs/code/environments/production/modules/netbox/manifests$
Navigate to the sudo mkdir /etc/puppetlabs/code/environments/production/modules/netbox/manifests$ and create a file called netbox_install.pp
sudo vi netbox_install.pp
Copy and paste the content below into the file (netbox_install.pp)
#This class will install netbox on Debian 9
class netbox::netbox_install {
#Install needed packages
Package { ensure => "installed"}
package { "libpq-dev":}
package { "python3":}
package { "python3-dev":}
package { "python3-setuptools":}
package { "build-essential":}
package { "libxml2-dev":}
package { "libxslt1-dev":}
package { "libffi-dev":}
package { "graphviz":}
package { "libssl-dev":}
package { "zlib1g-dev":}
package { "python3-pip":}
package { "git":}
package { "redis-server":}
package { "nginx":}
package { "supervisor":}
#Install postgresql to use as database
# Create a hash from Hiera Data with the Databases
$myPostgresDb = hiera('postgresql::server::db', {})
# With Create Resource Converts a hash into a set of resources
create_resources('postgresql::server::db', $myPostgresDb)
# Create the netbox user
user { 'netbox':
ensure => 'present',
comment => 'netbox',
managehome => false,
password => 'enigmT@2018',
}
# Create the netbox directory
file { '/opt/netbox':
ensure => directory,
owner => 'netbox',
group => 'netbox',
mode => '0766',
}
# Download netbox fron github.com
vcsrepo { '/opt/netbox':
ensure => present,
provider => git,
source => 'https://github.com/digitalocean/netbox.git',
user => 'netbox',