How to use controller tags (snap/3.1/CLI)

2.9 3.0 3.1
DEB CLI ~ UI CLI ~ UI CLI ~ UI
SNAP CLI ~ UI CLI ~ UI CLI ~ UI

This article will show you:

How to discover the ID of your region controller(s)

You can discover the ID of your region controller(s) with the following command:

maas $PROFILE region-controllers read \
| jq -r '(["name","id"]
|(.,map(length*"-"))),(.[]|[.hostname,.system_id])
| @tsv' | column -t

For example:

maas admin region-controllers read \
| jq -r '(["name","id"]
|(.,map(length*"-"))),(.[]|[.hostname,.system_id])
| @tsv' | column -t

Typical output would look something like this:

name                         id
----                         --
bill-Lenovo-Yoga-C740-15IML  86xya8

How to assign tags to a region controller

To add tags to a region controller, you can use a command of this form:

maas $PROFILE tag update-nodes $TAG_NAME add=$SYSTEM_ID

If you need to find the ID of your region controller(s), you can look it up.

For example:

maas admin tag update-nodes virtual add=86xya8

This command produces output similar to the following:

Success.
Machine-readable output follows:
{
    "added": 1,
    "removed": 0
}

You can check your work by listing all tags for your region controllers.

How to remove tags from a region controller

To remove tags from a region controller, you can use a command like this:

maas $PROFILE tag update-nodes $TAG_NAME remove=$SYSTEM_ID

If you need to find the ID of your region controller(s), you can look it up.

For example:

maas admin tag update-nodes virtual remove=86xya8

This command produces output similar to the following:

Success.
Machine-readable output follows:
{
    "added": 0,
    "removed": 1
}

You can check your work by listing all tags for your region controllers.

How to list tags for all region controllers

To list tags for all region controllers, you can use a command similar to this:

maas $PROFILE region-controllers read | jq -r '(["hostname","sysid","tags"]|(.,map(length*"-"))),(.[]|[.hostname,.system_id,.tag_names[]]) | @tsv' | column -t

For example:

maas admin region-controllers read | jq -r '(["hostname","sysid","tags"]|(.,map(length*"-"))),(.[]|[.hostname,.system_id,.tag_names[]]) | @tsv' | column -t

This will produce output something like this:

hostname                     sysid   tags
--------                     -----   ----
bill-Lenovo-Yoga-C740-15IML  86xya8  virtual  lxd-vm-host

How to view tags for one region controller

To view tags for a specific region controller, you can try a command like this:

maas $PROFILE region-controller read $SYSTEM_ID | jq -r '(["hostname","sysid","tags"]|(.,map(length*"-"))),([.hostname,.system_id,.tag_names[]]) | @tsv' | column -t

If you need to find the ID of your region controller(s), you can look it up.

For example:

maas admin region-controller read 86xya8 \
| jq -r '(["hostname","sysid","tags"]
|(.,map(length*"-"))),([.hostname,.system_id,.tag_names[]])
| @tsv' | column -t

This should produce output similar to the following:

hostname                     sysid   tags
--------                     -----   ----
bill-Lenovo-Yoga-C740-15IML  86xya8  virtual  lxd-vm-host

How to discover the ID of your rack controller(s)

You can discover the ID of your rack controller(s) with the following command:

maas $PROFILE rack-controllers read \
| jq -r '(["name","id"]
|(.,map(length*"-"))),(.[]|[.hostname,.system_id])
| @tsv' | column -t

For example:

maas admin rack-controllers read \
| jq -r '(["name","id"]
|(.,map(length*"-"))),(.[]|[.hostname,.system_id])
| @tsv' | column -t

Typical output would look something like this:

name                         id
----                         --
bill-Lenovo-Yoga-C740-15IML  86xya8

How to assign tags to a rack controller

To add tags to a rack controller, you can use a command of this form:

maas $PROFILE tag update-nodes $TAG_NAME add=$SYSTEM_ID

If you need to find the ID of your rack controller(s), you can look it up.

For example:

maas admin tag update-nodes virtual add=86xya8

This command produces output similar to the following:

Success.
Machine-readable output follows:
{
    "added": 1,
    "removed": 0
}

You can check your work by listing all tags for your rack controllers.

How to remove tags from a rack controller

To remove tags from a rack controller, you can use a command like this:

maas $PROFILE tag update-nodes $TAG_NAME remove=$SYSTEM_ID

If you need to find the ID of your rack controller(s), you can look it up.

For example:

maas admin tag update-nodes virtual remove=86xya8

This command produces output similar to the following:

Success.
Machine-readable output follows:
{
    "added": 0,
    "removed": 1
}

You can check your work by listing all tags for your rack controllers.

How to list tags for all rack controllers

To list tags for all rack controllers, you can use a command similar to this:

maas $PROFILE rack-controllers read | jq -r '(["hostname","sysid","tags"]|(.,map(length*"-"))),(.[]|[.hostname,.system_id,.tag_names[]]) | @tsv' | column -t

For example:

maas admin rack-controllers read | jq -r '(["hostname","sysid","tags"]|(.,map(length*"-"))),(.[]|[.hostname,.system_id,.tag_names[]]) | @tsv' | column -t

This will produce output something like this:

hostname                     sysid   tags
--------                     -----   ----
bill-Lenovo-Yoga-C740-15IML  86xya8  virtual  lxd-vm-host

How to view tags for one rack controller

To view tags for a specific rack controller, you can try a command like this:

maas $PROFILE rack-controller read $SYSTEM_ID | jq -r '(["hostname","sysid","tags"]|(.,map(length*"-"))),([.hostname,.system_id,.tag_names[]]) | @tsv' | column -t
'''

If you need to find the ID of your rack controller(s), you can [look it up](#heading--discover-the-id-of-your-rack-controllers).

For example:

```nohighlight
maas admin rack-controller read 86xya8 \
| jq -r '(["hostname","sysid","tags"]
|(.,map(length*"-"))),([.hostname,.system_id,.tag_names[]])
| @tsv' | column -t

This should produce output similar to the following:

hostname                     sysid   tags
--------                     -----   ----
bill-Lenovo-Yoga-C740-15IML  86xya8  virtual  lxd-vm-host

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.