Skip to content

Lab 03 Upgrade Nautobot and install apps

Lab Overview

Nautobot is easy to upgrade and highly customizable. In this lab we will be upgrading Nautobot to a more recent version as well as installing a number of popular apps and configuring Nautobot to use those apps.

Table of Contents

Lab 01 - Upgrade Nautobot and install apps

Task 1 - Upgrade Nautobot

Step 1-1 - Login via ssh to the Nautobot installation

As a first step, you will upgrade your Nautobot version. Connect via ssh to your Nautobot pod as the ntc user. Use the password provided by the instructor.

ssh ntc@{{ your pod }}

Verify you are logged in as the ntc user

ntc@ntc-nautobot:~# whoami
ntc

Change to the nautobot user. No nautobot password is needed when starting from the ntc account.

ntc@ntc-nautobot:~# sudo -iu nautobot
nautobot@ntc-nautobot:~$ whoami
nautobot
nautobot@ntc-nautobot:~$ pwd
/opt/nautobot
nautobot@ntc-nautobot:~$

Step 1-2 - Nautobot upgrade details

Details about how to upgrade Nautobot may be found at https://nautobot.readthedocs.io/en/latest/installation/upgrading/

Please note that this is a somewhat SIMPLIFIED PROCESS. In the real world, it is important to follow the documented upgrade instructions carefully, considering potential issues such as dependency versions and whether the upgrade is comparatively minor (e.g. 1.2.5 -> 1.2.9 where only the third version digit changes) or major (e.g. 1.1.0 -> 1.1.2 or 1.2.5 to 1.3.0 where the first or second version digit changes).

You can read more about semantic versioning at https://semver.org/

Step 1-3 - Check versions of Nautobot prerequisites

Let's check the versions some basic Nautobot prerequisite products

Python (of course!)

nautobot@ntc-nautobot:~$ python3 --version
Python 3.8.10
pip for package management
nautobot@ntc-nautobot:~$ pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
PostgreSQL (database)
nautobot@ntc-nautobot:~$ psql --version
psql (PostgreSQL) 12.15 (Ubuntu 12.15-0ubuntu0.20.04.1)
Redis (in-memory data structure store)
nautobot@ntc-nautobot:~$ redis-server --version
Redis server v=5.0.7 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=66bd629f924ac924

Check the installed version of Nautobot. As you can see, some Nautobot Apps are also installed, but they will not appear in the Nautobot GUI just yet because the config file has not been configured. We'll do that later in this lab.

nautobot@ntc-nautobot:~$ pip list | grep -i nautobot
nautobot                        1.5.12
nautobot-data-validation-engine 1.0.0
nautobot-device-lifecycle-mgmt  1.1.2

(Though not used on this pod configuration, you may check the mysql version with the command mysqld --version.)

Step 1-4 If necessary, upgrade any prerequisite product versions to meet the minimums

Confirm that the versions of these prerequisite products are at least as high as those stated in the upgrade instructions. An example of that is:

Nautobot v1.6.0 and later requires the following:

Dependency Minimum Version
Python 3.8
PostgreSQL 9.6
Redis 4.0

Step 1-5 - Install the desired Nautobot version

Time to upgrade the Nautobot version, use pip3 and specify version 1.5.23. If a version is not included, Nautobot will update to the most recent release. Beware! The labs in this course have been tested against Nautobot 1.5.23, so please stick with that version.

nautobot@ntc-nautobot:~$ pip3 install --upgrade nautobot==1.5.23
Check the version of Nautobot
nautobot@ntc-nautobot:~$ pip list | grep -i nautobot
nautobot                        1.5.23

Step 1-6 - Upgrade Optional Dependencies

If you do not have any optional dependencies, you may skip this step.

Once the new code is in place, verify that any optional python packages required by your deployment (e.g. napalm or django-auth-ldap) are listed in a file named local_requirements.txt. For the purposes of this class, we are going to install the Welcome Wizard app to help us populate Nautobot in later labs.

You can create local_requirements.txt with the command touch local_requirements.txt or in VS Code, or using your preferred editor such as nano or vim. Using your preferred method, create and edit local_requirements.txt so there is a single line at the top that says nautobot-welcome-wizard==1.1.4 and save the file.

local_Requirements.txt

nautobot-welcome-wizard==1.1.4
Then, upgrade your dependencies using pip3. The environment variable $NAUTOBOT_ROOT and other variables can be found in nautobot.env
nautobot@ntc-nautobot:~$ pip3 install --upgrade -r $NAUTOBOT_ROOT/local_requirements.txt
Check the installed version of the Welcome Wizard app.
nautobot@ntc-nautobot:~$ pip list | grep -i welcome-wizard
nautobot-welcome-wizard         1.1.4

Step 1-7 - Run post upgrade operations

Finally, run Nautobot's post_upgrade management command. Depending on how big of a version jump is being made, you may see a rather lengthy output, that is expected. The post_upgrade command runs a number of commands in the correct order. The most helpful things it does for you are:

  • Applies any database migrations that were included in the release
  • Generates any missing cable paths among all cable termination objects in the database
  • Collects all static files to be served by the HTTP service
  • Deletes stale content types from the database
  • Deletes all expired user sessions from the database
  • Clears all cached data to prevent conflicts with the new release
nautobot@ntc-nautobot:~$ nautobot-server post_upgrade
Performing database migrations...
Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, database, dcim, django_celery_beat, django_rq, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization
Running migrations:
  No migrations to apply.

Generating cable paths...
Found no missing circuit termination paths; skipping
Found no missing console port paths; skipping
Found no missing console server port paths; skipping
Found no missing interface paths; skipping
Found no missing power feed paths; skipping
Found no missing power outlet paths; skipping
Found no missing power port paths; skipping
Finished.

Collecting static files...

0 static files copied to '/opt/nautobot/static', 735 unmodified.

Removing stale content types...

Removing expired sessions...

Invalidating cache...

Step 1-8 - Restart the Nautobot Services

Finally, with root permissions, restart the web and background services. Exit from the nautobot user and verify that you are logged in as the ntc user before attempting to restart the Nautobot services. If all we were doing was upgrading the Nautobot version, we would be done and ready to resume using Nautobot. However, in this lab we are going to install a few plugins, which will require another restart later.

nautobot@ntc-nautobot:~$ exit
logout
Restart the Nautobot services.
ntc@ntc-nautobot:~# sudo systemctl restart nautobot nautobot-worker nautobot-scheduler
ntc@ntc-nautobot:~# 

Task 2 - Create a Nautobot superuser account

Step 2-1 - Login via ssh to the Nautobot installation

If not already done, use the Lab 0 access instructions to log in to your pod as user ntc with the password provided by the instructor.

Step 2-2 - Create a Nautobot superuser account

Switch back to the nautobot user. Note that the beginning prompt on a command line shows the current user (ntc or nautobot) followed by the @ symbol.

ntc@ntc-nautobot:~# sudo -iu nautobot

If you are familiar with Django, the nautobot-server command is custom version of the Django manage command. To see a list of available subcommands, use nautobot-server help

nautobot@ntc-nautobot:~# nautobot-server help
Type 'nautobot-server help <subcommand>' for help on a specific subcommand.

Available subcommands:

[auth]
    changepassword
    createsuperuser

[cacheops]
    cleanfilecache
    invalidate

[constance]
    constance

[contenttypes]
    remove_stale_contenttypes

[core]
    celery
    generate_secret_key
    generate_test_data
    post_upgrade
    start
    startplugin
    validate_models

[dcim]
    trace_paths

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    sendtestemail
    shell
    showmigrations
    sqlflush
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    test
    testserver

[django_extensions]
    admin_generator
    clean_pyc
    clear_cache
    compile_pyc
    create_command
    create_jobs
    create_template_tags
    delete_squashed_migrations
    describe_form
    drop_test_database
    dumpscript
    export_emails
    find_template
    generate_password
    graph_models
    list_model_info
    list_signals
    mail_debug
    managestate
    merge_model_instances
    notes
    pipchecker
    print_settings
    print_user_for_session
    raise_test_exception
    reset_db
    reset_schema
    runjobs
    runprofileserver
    runscript
    runserver_plus
    set_default_site
    set_fake_emails
    set_fake_passwords
    shell_plus
    show_template_tags
    show_urls
    sqlcreate
    sqldiff
    sqldsn
    sync_s3
    syncdata
    unreferenced_files
    update_permissions
    validate_templates

[django_jinja]
    makemessages

[django_rq]
    rqenqueue
    rqscheduler
    rqstats

[drf_spectacular]
    spectacular

[extras]
    fix_custom_fields
    nbshell
    remove_stale_scheduled_jobs
    renaturalize
    rqworker
    runjob
    webhook_receiver

[graphene_django]
    graphql_schema

[health_check]
    health_check

[rest_framework]
    generateschema

[sessions]
    clearsessions

[social_django]
    clearsocial

[staticfiles]
    collectstatic
    findstatic
    runserver

[utilities]
    makemigrations
    migrate

If the nautobot-server help command is not found, make sure you are now running as the user nautobot, not ntc.

To create a superuser, use nautobot-server createsuperuser and follow the prompts. The only required information is a username and password.

nautobot@ntc-nautobot:~# nautobot-server createsuperuser
Username: David
Email address:
Password:
Password (again):
Superuser created successfully.

Task 3 - Start the Nautobot GUI and verify that the Welcome Wizard app isn't installed.

Step 3-1 - Login via a web browser to Nautobot

In a web browser, open the URL https://{{ your pod }}. Log in with the username and password previously established.

image03-1

Step 3-2 - Verify that Welcome Wizard isn't installed

In the list of menu items to the right of the Nautobot logo in the top left corner, click on Plugins. Under that, you shouldn't see the lines Nautobot Welcome Wizard and Welcome Wizard.

image03-1

Task 4 - Install additional apps and configure Nautobot

Step 4-1 - Welcome Wizard overview

In a web browser, go to https://github.com/nautobot/nautobot-plugin-welcome-wizard to see various details including installation instructions in the README.md text. You can also read detailed installation instructions at the Welcome Wizard administrator guide: https://docs.nautobot.com/projects/welcome-wizard/en/latest/admin/install/.

Step 4-2 - Login via ssh to the Nautobot host

Connect via ssh to your Nautobot pod as the ntc user and verify working directory.

ntc@ntc-nautobot:~# whoami
ntc
ntc@ntc-nautobot:~# pwd
/home/ntc

Change to the nautobot user. No nautobot password is needed when starting from the ntc account.

ntc@ntc-nautobot:~# sudo -iu nautobot
nautobot@ntc-nautobot:~$ whoami
nautobot
nautobot@ntc-nautobot:~$ pwd
/opt/nautobot

Step 4-3 - Installing Nautobot apps via pip

NTCU - SKIP

Step 4-5 - Run Post Upgrade

We've installed some additional apps, so let's run post_upgrade. Don't forget this step or your database might not be ready for the new apps!

nautobot@ntc-nautobot:~$ nautobot-server post_upgrade

Step 4-6 - Restart Nautobot services

The last step is to restart the Nautobot services, this is required for Nautobot to recognize the changes to the config file and load up our newly installed apps. This must be done as the ntc user, so be sure to exit from the nautobot user first.

nautobot@ntc-nautobot:~$ exit
logout
ntc@ntc-nautobot:~# whoami
ntc
ntc@ntc-nautobot:~# sudo systemctl restart nautobot nautobot-worker

Task 5 - Verify the app status and Nautobot version

Step 5-1 - Login via a web browser to Nautobot

In a web browser, go back to or re-open the URL https://{{ you pod }}. If necessary, log in with the username and password previously established.

Step 5-2 Verify the new Nautobot version

Check the Nautobot version on the lower left-hand corner of the Nautobot home page.

image05-1

Step 5-3 - Verify the apps are installed

From the menus at the top of the page select Plugins and Installed Plugins. The installed apps and their versions should be displayed.

image05-2