Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
NAPALM added, VM resources shrunk down, minor updates - closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmerolle committed Feb 21, 2018
1 parent aa08c3f commit 660d28c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 61 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ To get NetBox up and running:
4. Log into VM (optional)
```# vagrant ssh```
5. Play with Netbox demo in browser of choice [http://netbox.localhost:8080](http://netbox.localhost:8080) (Admin credentials use "admin" for userid and password - can be changed & credentials do not have quotes)
6. (Optional) [NAPALM Config](http://netbox.readthedocs.io/en/stable/configuration/optional-settings/#napalm_username), [Email Config](http://netbox.readthedocs.io/en/stable/configuration/optional-settings/#email), [LDAP](http://netbox.readthedocs.io/en/stable/installation/ldap/)

## Upgrading
The [normal NetBox upgrade process](https://github.com/digitalocean/netbox/blob/develop/docs/installation/upgrading.md) can be followed using the instructions to Clone the Git Repository (latest master release).

## Netbox Configuration Used
The [NetBox installation](https://github.com/digitalocean/netbox/blob/develop/docs/installation/netbox.md) process is followed leveraging:

* VM Memory: 4096 (edit Vagrantfile if you would like to change)
* VM CPUs: 2
* VM Memory: 2048 (edit Vagrantfile if you would like to change)
* VM CPUs: 1 (edit Vagrantfile if you would like to change)
* Ubuntu Xenial64 (updated)
* Python 2
* Cloning the Git Repository (as opposed to downloading a tar of a particular release)
* Apache (I'll convert this to ngnix soon)
* Python 3 (deprecated python2)
* GIT - Cloning the Netbox latest master release from github (as opposed to downloading a tar of a particular release)
* Ngnix (deprecated Apache)

## Security
* Netbox/Django superuser account is ```admin``` with a password ```admin``` and an email of ```admin@example.com``` (can be changed after startup)
Expand All @@ -42,11 +43,12 @@ The [NetBox installation](https://github.com/digitalocean/netbox/blob/develop/do
* [Vagrant Credentials](https://www.vagrantup.com/docs/boxes/base.html#default-user-settings) - to understand credentials used for vagrant / Ubuntu VM

## Notes
* [bootstrap.sh](bootstrap.sh) can be used to bootstrap any Ubuntu Xenial setup & not just Vagrant
* netbox-vagrant setup files are deleted once VM is fully provisioned
* [bootstrap.sh](bootstrap.sh) can be used to bootstrap any Ubuntu Xenial setup & not just Vagrant (with slight tweaking)
* Additional Support Resources include:
* [NetBox Github page](https://github.com/digitalocean/netbox/)
* [NetBox Read the Docs](http://netbox.readthedocs.io/en/stable/)
* [NetBox-discuss mailing list](https://groups.google.com/forum/#!forum/netbox-discuss)
* [NAPALM Github page](https://github.com/napalm-automation/napalm/)
* [NAPALM Read the Docs](https://napalm.readthedocs.io/)
* [Join the Network to Code community on Slack](https://networktocode.herokuapp.com) - Once setup join the **#netbox** room for help. I'm **ryanmerolle** & usually in this slack room.
* Join NetBox community on IRC in **#netbox** on **irc.freenode.net**! (@ryanmerolle does not join currently)
15 changes: 10 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.hostname = "Netbox-Demo"
config.vm.hostname = "netbox-demo"

config.vm.network :forwarded_port, guest: 80, host: 8080, id: 'http'

config.vm.synced_folder "./config_files", "/vagrant"

#Update VM resources below as needed
config.vm.provider :virtualbox do |vb|
vb.name = "Netbox-Demo"
vb.memory = 4096
vb.cpus = 2
vb.memory = 2048
vb.cpus = 1
vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"]
end

config.vm.network :forwarded_port, guest: 80, host: 8080, id: 'http'
config.vm.provision :shell, path: "bootstrap.sh"
end

end
90 changes: 41 additions & 49 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,48 @@
# Prevent
export DEBIAN_FRONTEND=noninteractive

# Install Git
printf "Step 1 of 20: Installing git & cloning netbox-vagrant...\n"
apt-get install git -y -qq > /dev/null
cd /tmp/ && git clone -b master https://github.com/ryanmerolle/netbox-vagrant.git

# Update Ubuntu
printf "Step 2 of 20: Updating Ubuntu...\n"
apt-get update -y -qq > /dev/null
printf "Step 1 of 19: Updating Ubuntu..."
apt-get update -y > /dev/null

# Install Postgres & start service
printf "Step 3 of 20: Installing & starting Postgres...\n"
apt-get install postgresql libpq-dev -y -qq > /dev/null
printf "Step 2 of 19: Installing & starting Postgres..."
apt-get install postgresql libpq-dev -y > /dev/null
sudo service postgresql start

# Setup Postgres with netbox user, database, and permissions
printf "Step 4 of 20: Setup Postgres with netbox user, database, & permissions."
printf "Step 3 of 19: Setup Postgres with netbox user, database, & permissions."
sudo -u postgres psql -c "CREATE DATABASE netbox"
sudo -u postgres psql -c "CREATE USER netbox WITH PASSWORD 'J5brHrAXFLQSif0K'"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox"

# Install nginx
printf "Step 5 of 20: Installing nginx...\n"
apt-get install nginx -y -qqm> /dev/null
printf "Step 4 of 19: Installing nginx..."
apt-get install nginx -y > /dev/null

# Install Python 2
printf "Step 6 of 20: Installing Python 3 dependencies...\n"
apt-get install python3 python3-dev python3-pip libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev -y -qq > /dev/null
printf "Step 5 of 19: Installing Python 3 dependencies..."
apt-get install python3 python3-dev python3-pip libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev -y > /dev/null

# Upgrade pip
printf "Step 7 of 20: Upgrade pip\n"
pip3 install --upgrade pip
printf "Step 6 of 19: Upgrading pip\n"
pip3 install --upgrade pip > /dev/null

# Install gunicorn & supervisor
printf "Step 8 of 20: Installing gunicorn & supervisor...\n"
printf "Step 7 of 19: Installing gunicorn & supervisor..."
pip3 install gunicorn
apt-get install supervisor -y -qq > /dev/null
apt-get install supervisor -y > /dev/null

printf "Step 9 of 20: Cloning NetBox repo...\n"
# Create netbox base directory & navigate to it
mkdir -p /opt/netbox/ && cd /opt/netbox/
printf "Step 8 of 19: Cloning NetBox repo latest stable release..."
# git clone netbox master branch
git clone -b master https://github.com/digitalocean/netbox.git .
git clone -b master https://github.com/digitalocean/netbox.git /opt/netbox

# Install NetBox requirements
printf "Step 10 of 20: Installing NetBox requirements...\n"
# pip install -r requirements.txt
pip3 install -r requirements.txt
printf "Step 9 of 19: Installing NetBox requirements..."
pip3 install -r /opt/netbox/requirements.txt > /dev/null

# Use configuration.example.py to create configuration.py
printf "Step 11 of 20: Configuring Netbox...\n"
printf "Step 10 of 19: Configuring Netbox..."
cp /opt/netbox/netbox/netbox/configuration.example.py /opt/netbox/netbox/netbox/configuration.py
# Update configuration.py with database user, database password, netbox generated SECRET_KEY, & Allowed Hosts
sed -i "s/'USER': '', /'USER': 'netbox', /g" /opt/netbox/netbox/netbox/configuration.py
Expand All @@ -64,44 +56,44 @@ sed -i "s~SECRET_KEY = ''~SECRET_KEY = '$SECRET_KEY'~g" /opt/netbox/netbox/netbo
unset SECRET_KEY

# Setup apache, gunicorn, & supervisord config using premade examples (need to change netbox-setup)
printf "Step 12 of 20: Configuring nginx...\n"
cp /tmp/netbox-vagrant/config_files/nginx-netbox.example /etc/nginx/sites-available/netbox
printf "Step 13 of 20: Configuring gunicorn...\n"
cp /tmp/netbox-vagrant/config_files/gunicorn_config.example.py /opt/netbox/gunicorn_config.py
printf "Step 14 of 20: Configuring supervisor...\n"
cp /tmp/netbox-vagrant/config_files/supervisord-netbox.example.conf /etc/supervisor/conf.d/netbox.conf
printf "Step 11 of 19: Configuring nginx..."
cp /vagrant/nginx-netbox.example /etc/nginx/sites-available/netbox
printf "Step 12 of 19: Configuring gunicorn..."
cp /vagrant/gunicorn_config.example.py /opt/netbox/gunicorn_config.py
printf "Step 13 of 19: Configuring supervisor..."
cp /vagrant/supervisord-netbox.example.conf /etc/supervisor/conf.d/netbox.conf

# Apache Setup (enable the proxy and proxy_http modules, and reload Apache)
printf "Step 15 of 20: Completing web service setup...\n"
printf "Step 14 of 19: Completing web service setup..."
cd /etc/nginx/sites-enabled/
rm default
ln -s /etc/nginx/sites-available/netbox
service nginx restart
service supervisor restart

# Install the database schema
printf "Step 16 of 20: Install the database schema...\n"
python3 /opt/netbox/netbox/manage.py migrate
printf "Step 15 of 19: Install the database schema..."
python3 /opt/netbox/netbox/manage.py migrate > /dev/null

# Create admin / admin superuser
printf "Step 17 of 20: Create NetBox superuser...\n"
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | python3 /opt/netbox/netbox/manage.py shell --plain
printf "Step 16 of 19: Create NetBox superuser..."
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | python3 /opt/netbox/netbox/manage.py shell --plain > /dev/null

# Collect Static Files
printf "Step 18 of 20: collectstatic\n"
python3 /opt/netbox/netbox/manage.py collectstatic --no-input <<<yes
printf "Step 17 of 19: collectstatic"
python3 /opt/netbox/netbox/manage.py collectstatic --no-input <<<yes > /dev/null

# Load Initial Data (Optional) Comment out if you like
printf "Step 19 of 20: Load intial data.\n"
python3 /opt/netbox/netbox/manage.py loaddata initial_data
printf "Step 18 of 19: Load intial data."
python3 /opt/netbox/netbox/manage.py loaddata initial_data > /dev/null

# Cleanup netbox-vagrant setup
printf "Step 20 of 20: Cleaning up netbox-vagrant setup files...\n"
rm -rf /tmp/netbox-vagrant/
printf "netbox-vagrant setup files deleted...\n"
# Install NAPALM Drivers
printf "Step 19 of 19: Installing NAPALM Drivers"
python3 /opt/netbox/netbox/manage.py loaddata initial_data > /dev/null

# Status Complete
printf "%s\nCOMPLETE: NetBox-Demo Provisioning COMPLETE!!\n"
printf "%s\nTo login to the Vagrant VM use vagrant ssh in the current directory\n"
printf "%s\nTo login to the Netbox-Demo web portal go to http://netbox.localhost:8080\n"
printf "%s\nWeb portal superuser credentials are admin / admin\n"
printf "%s\nCOMPLETE: NetBox-Demo Provisioning COMPLETE!!"
printf "%s\nTo login to the Vagrant VM use vagrant ssh in the current directory"
printf "%s\nSee NAPALM and Netbox documentation to get NAPALM working with Netbox and your environment"
printf "%s\nTo login to the Netbox-Demo web portal go to http://netbox.localhost:8080"
printf "%s\nWeb portal superuser credentials are admin / admin"

0 comments on commit 660d28c

Please sign in to comment.