Docs
Tutorial

A second design

Put a site and its /16 supernet in a country from your first design, and meet variables.

The second design creates a site in one of the countries from your first design, and a /16 supernet for the site's subnets. Unlike the first, it asks you for values when you plan it.

Read the design

name: Site Foundation
netbox_versions: ["4.6.*", "4.7.*"]
description: A site in a country, with a /16 supernet for its subnets.
variables:
  site_name: {type: netbox_new, model: Site, field: name, description: "The site's name, as NetBox shows it"}
  site_slug: {type: netbox_new, model: Site, field: slug, description: "The site's slug, in letters, digits and hyphens"}
  region: {type: netbox_ref, model: Region, description: A country from your first design}
  supernet: {type: cidr, description: "The site's /16, such as 10.20.0.0/16"}
  status: active
infra:
- infra_type: Site
  name: '{{ variables.site_name }}'
  slug: '{{ variables.site_slug }}'
  status: '{{ variables.status }}'
  region: '{{ variables.region }}'
- infra_type: Prefix
  prefix: '{{ variables.supernet }}'
  status: container
  site: '{{ variables.site_slug }}'
  description: 'Site supernet for {{ variables.site_name }}'
  • variables declares the design's inputs, and what each is. site_name and site_slug are a new site's name and slug (netbox_new), checked against what NetBox takes for them, so a slug with a space in it is refused before anything plans; region is a region your NetBox already has (netbox_ref); supernet is an IP prefix (cidr). The deploy page asks for each in its own form, with the description under it. status: active is a default, so the deploy page doesn't ask for it. A variable can also be declared as just $USER, which asks for text and checks nothing.
  • {{ variables.site_name }} is replaced with the value you give. Expressions like this can appear anywhere a value can.
  • region: '{{ variables.region }}' names a region your first design created. A reference written as text finds its object by the object's name or slug, so Latvia and latvia both work.
  • site: '{{ variables.site_slug }}' places the prefix in the site the same design creates.

Variables covers them in more depth.

Add it and plan it

  1. Add the design to the catalogue as tutorial/site_foundation, as you did the first.

  2. Open it and select Deploy, then choose your NetBox.

  3. Leave New deployment selected, with the name site_foundation.

  4. Under Variables, fill in the four the design asks for:

    VariableValue
    site_nameRiga DC
    site_slugriga-dc
    regionLatvia
    supernet10.10.0.0/16
  5. Select Plan.

The plan has 2 creates: the site and the prefix. A region that names none in NetBox, or in the design, refuses the plan instead, saying which.

Apply it and look

Apply the plan. In NetBox, the site Riga DC is in the region Latvia, and the prefix 10.10.0.0/16 is a container scoped to it.

Plan the deployment again from Deployments, as before: there's nothing to do.

Next, the compute rack puts a rack in this site, built from other designs.

On this page