Netbox installation notes for CentOs 6/7

1,423 views
Skip to first unread message

fr

unread,
Mar 6, 2017, 1:15:16 AM3/6/17
to NetBox

Preamble:


Hi All,


I’m a relatively inexperienced user, training to be a SA/DevOps guy who’s recently taken it upon himself to deploy the netbox db/app on Centos 6/7 respectively. While I’m aware that the deployment has been dockerized, and well documented on Debian based systems I thought I could learn something by taking the road less traveled.


My goal with this document is to share some of the pitfalls I encountered while trying to adapt the installation documents to my process, in the hopes this can save others some time/effort in deploying the app under similar conditions.


Installation parameters:


  • Centos 6 (referred to as host 1):

    • PostgreSQL server.

  • Centos 7 (referred to as host 2):

    • Python 2

    • Httpd stack

    • Supervisord

    • Gunicorn



Database Preparation:


Starting with this document as a template modify the process as following:


  1. yum install -y postgresql postgresql-server postgresql-devel python-psycopg2

  2. postgresql-setup initdb

    1. sudo service postgresql initdb

  3. sudo vi /var/lib/pgsql/data/pg_hba.conf -> replace ident with md5

    1. Postpone this until after you have created the db user, attempt logging in

    2. If you can’t login try setting the password via sudo passwd postgresql

  4. sudo -u postgres psql

    1. Follow commands given in the document, use unique password for netbox user, as it will be stored in plaintext on your app host.

  5. sudo vi /var/lib/pgsql/data/pg_hba.conf

    1. Now replace the auth with md5

    2. Add a line -> host    all     all    *full CIDR IP Address of host 2*    trust

  6. sudo vi /var/lib/pgsql/data/postgresql.conf

    1. Uncomment and edit line: listen_addresses = “octet IP address of host 1”

    2. Uncomment port line

  7. Make iptables rules

    1. sudo iptables -I INPUT 5 -p udp --dport 5432 -j ACCEPT

    2. sudo iptables -I INPUT 5 -p tcp --dport 5432 -j ACCEPT

  8. Make iptables rules permanent

    1. sudo iptables-save > /etc/iptables.conf

    2. sudo vi /etc/rc.conf -> add line

      1. Iptables-restore < /etc/iptables.conf

  9. sudo service psql restart


App host setup: Netbox Install


On installing the requirements:


  1. I tried installing the required python packages on top of Python3, but found that pip wasn’t in my PATH. So, for the sake of convenience I suggest using Python2, after which pip just worked for me.

  2. While it's possible to git clone the current state of the project, I had some trouble getting gunicorn to serve the app, which may have been related to the fact that I wasn’t working on a stable release.

  3. While it should be technically possible to unpack and run the project from a folder other than /opt/netbox, I recommend getting an install running at this location before making changes as there are a lot of moving parts with regards to apache, gunicorn, and supervisord. If you really feel like putting it elsewhere, just use symlinks :)

Starting with this document, modify the following:


  1. Get the required packages using yum

  2. Download the latest stable release from https://github.com/digitalocean/netbox/releases using wget

  3. Using the doc as a guide, unpack the contents to /opt/ and symlink the resulting folder to /opt/netbox

  4. From /opt/netbox

    1. sudo pip install -r requirements.txt

    2. sudo ./generate_secret_key.py

      1. copy the key down.

  5. From /opt/netbox/netbox

    1. sudo cp configuration.example.py configuration.py

    2. Edit the new configuration.py according to instructions

    3. Under “ALLOWED_HOSTS” edit target field to be ’*’

  6. Under /opt/netbox/netbox/ do the following according to instructions with sudo

    1. ./manage.py migrate

    2. ./manage.py createsuperuser

    3. ./manage.py collectstatic

    4. ./manage.py loaddata initial_data

  7. Try running the dev server to see if it throws any errors.



App host setup: Server Setup


On installing the requirements:


  1. From this part of the guide on I am assuming that you’ve got httpd up and running, and firewall rules to allow your web server to be reached. For guides on how to do that check out digitalocean’s wiki:


Starting with this document, modify the following:

  1. sudo pip install gunicorn

  2. sudo yum install supervisor

  3. sudo vi /etc/httpd/conf.d/netbox.conf

    1. Insert the two following lines at the top of the file

      1. LoadModule proxy_module modules/mod_proxy.so

      2. LoadModule proxy_http_module modules/mod_proxy_http.so

    2. Copy the template from the instructions to the rest of the file, save it.

  4. sudo systemctl restart httpd

  5. sudo vi /opt/netbox/netbox/gunicorn_config.py

    1. Use the suggested template provided and replace www-data with apache

  6. sudo vi /etc/supervisord.conf

    1. Add line ‘files = supervisord.d/*.conf’

  7. sudo vi /etc/supervisord.d/netbox.conf

    1. Create file according to the template, replace www-data with apache

  8. sudo systemctl restart supervisord

  9. sudo supervisorctl add netbox

  10. sudo supervisorctl start netbox


cw...@tacc.utexas.edu

unread,
Jan 24, 2018, 11:26:55 AM1/24/18
to NetBox
For the part,

6. sudo vi /etc/supervisord.conf
    1. Add line ‘files = supervisord.d/*.conf


Where in the file should you including the line?
I put in under the [include] section however when I go to add netbox It is unable to be found.


Reply all
Reply to author
Forward
0 new messages