Using network tags

Maastering network interface tags

Get to grips with the nitty-gritty of network interface tags in MAAS. With these tabs, you’ll find the steps laid out for both UI and CLI users.

Network tags with the UI

Note: In the operations that follow, autocomplete might be scarce, as interface tags don’t usually carry over between machines with different MAC addresses.

Creating and tagging network interfaces

To slap a tag onto an interface:

  1. Navigate to Machines.
  2. Choose the machine linked to the target interface.
  3. Go to Network.
  4. Hit Edit physical on the row for your chosen interface.
  5. Look for the Tags field.
  6. Type in your new tag.
  7. Finalise by clicking Save interface.

Erasing tags

To remove a tag from an interface:

  1. Navigate to Machines.
  2. Choose the machine linked to the target interface.
  3. Go to Network.
  4. Hit Edit physical on the row for your chosen interface.
  5. Look for the Tags field.
  6. Click the X next to the tag you want gone.
  7. Seal the deal by clicking Save interface.

Peering into tagland

To scrutinise the tags on an interface:

  1. Navigate to Machines.
  2. Choose the machine linked to the target interface.
  3. Go to Network.
  4. Hit Edit physical on the row for your chosen interface.
  5. Observe the Tags field.
  6. Click Cancel when done marvelling.

Network tags with the CLI

Discover your interface’s ID

Identify your network interfaces with a command akin to this:

maas $PROFILE interfaces read $SYSTEM_ID \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),(.[]|[.mac_address,.type,.id,.tags[]])
|@tsv'| column -t

Example:

maas admin interfaces read xn8taa \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),(.[]|[.mac_address,.type,.id,.tags[]])
|@tsv'| column -t

Expect output like:

mac_address        type      id  tags
-----------        ----      --  ----
00:16:3e:18:7f:ee  physical  9   andrpko  plinko  cochise

Tag it up, CLI style

Tag your network interface with this command format:

maas $PROFILE interface add-tag $SYSTEM_ID $INTERFACE_ID tag=$TAG_NAME

Example:

maas admin interface add-tag xn8taa 9 tag=farquar

You’ll see a verbose JSON output revealing the changes.

CLI tag deletion

To exterminate a tag:

maas $PROFILE interface remove-tag $SYSTEM_ID $INTERFACE_ID tag=$TAG_NAME

Example:

maas admin interface remove-tag xn8taa 9 tag=farquar

You’ll be greeted with a JSON output that confirms the tag’s removal.

Tag census

List all tags with:

maas $PROFILE interfaces read $SYSTEM_ID \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),(.[]|[.mac_address,.type,.id,.tags[]])
|@tsv'| column -t

Example:

maas admin interfaces read xn8taa \
| jq -r '(["mac_address","type","id","tags"]
|(.,map(length*"-"))),(.[]|[.mac_address,.type,.id,.tags[]])
|@tsv'| column -t

Expect output like:

mac_address        type      id  tags
-----------        ----      --  ----
00:16:3e:18:7f:ee  physical  9   andrpko  plinko  cochise  farquar

Single-interface tag viewing

To scope out tags on a specific interface:

maas $PROFILE interface read $SYSTEM_ID $INTERFACE_ID \
| jq '.tags'

Example:

maas admin interface read xn8taa 9 | jq '.tags'

Anticipate a JSON output displaying the tags.


Last updated a month ago.