Skip to content

Adding a New Device to Nautobot

Nautobot is the Source of Truth (SoT) aggregation layer that has been chosen. In this section, you will review how to create a new Device in Nautobot and the dependencies that need to be satisfied to accomplish this task.

How to add a new device to Nautobot

First, you will review the necessary dependencies on multiple levels in order to create a Nautobot device. Then you will review three methods to execute this task:

  1. Using the web UI.
  2. Using the Nautobot Ansible Collections.
  3. Using API calls.

Dependencies

There are three levels of dependencies that affect the creation of a Nautobot device. These dependencies align with the goal of Nautobot to represent real world devices with the required characteristics:

First level:

  • Site: A device has a physical location, therefore a Site object is required to represent this location. Sites depend on the nature of your organization, for example a site for a bank may be a branch.
  • Device Type: A device has a specific model, therefore a DeviceType object needs to be created to characterize it. Once a device type is added to the device, its default components such as console ports, power ports, and interfaces will be assigned to it.
  • Device Role: A DeviceRole object indicates the function of a device within an organization, whether it operates as a core/distribution/access switch, router, firewall etc. It is a first level dependency since a device always has a specific purpose.

Second level:

  • Site
    • name: To create a Site a unique name needs to be provided as a string.
    • slug: A slug string is required to standardize how the name is referenced.
  • Device Type
    • Manufacturer: A Manufacturer object, i.e., the "make" of a device, needs to be assigned to each DeviceType.
    • model: The model is a unique name provided as a string.
    • slug: A slug string is required to standardize how the name is referenced.
  • Device Role
    • name: The unique name of the role needs to be provided as a string.
    • slug: A slug string is required to standardize how the name is referenced.

Third level:

  • Manufacturer
    • name: To create a Manufacturer object you need to provide a name as a string.
    • slug: A slug string is required to standardize how the name is referenced.

Next, you will review three different ways to satisfy these dependencies.

Using the Web Interface

NTCU - SKIP

Using Ansible

There is a rich set of Ansible Collections for Nautobot that can perform all the above operations programmatically:

  1. Create a Site:

    Below we show an example with Sites corresponding to states.

    - name: "Test Nautobot site module"
      connection: local
      hosts: localhost
      gather_facts: False
      tasks:
        - name: Create site within Nautobot with only required information
          networktocode.nautobot.site:
            url: http://nautobot.local
            token: thisIsMyToken
            name: Test - Colorado
            status: active
            state: present
    
  2. Create a Device Type & Manufacturer:

    A set of random manufacturers with name Test Manufacturer is created and then a set of test device types, with model DEV-01. Each name string has two digits concatenated at the end.

        - name: Create manufacturer within Nautobot with only required information
          networktocode.nautobot.manufacturer:
            url: http://nautobot.local
            token: thisIsMyToken
            name: Test Manufacturer
            state: present
    
      - name: Create device type within Nautobot with only required information
        networktocode.nautobot.device_type:
          url: http://nautobot.local
          token: thisIsMyToken
          slug: test-device-type
          model: DEV-01
          manufacturer: Test Manufacturer
          state: present
    
  3. Create a Device Role:

    Device roles are created from a list of device roles in the example below.

    - name: Create device role within Nautobot with only required information
      networktocode.nautobot.device_role:
        url: http://nautobot.local
        token: thisIsMyToken
        name: Test device role
        color: FFFFFF
        state: present
    
  4. Create a Device:

    Finally, a device is created with the role, site, and type previously created.

    - name: Create device within Nautobot with only required information
      networktocode.nautobot.device:
        url: http://nautobot.local
        token: thisIsMyToken
        name: Test Device
        device_type: test-device-type
        device_role: Test device role
        site: Test - Colorado
        status: active
        state: present