Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • Create and access a list of your products

Using Tags with MAAS and Juju in Ubuntu Server 14.04 LTS

Summary: MAAS implements a system of tags based on the physical properties of the nodes. The MAAS documentation on tags discusses this

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Symptoms

This article was written Mark Wenning, Canonical Field Engineer.

Tags for finer control of MAAS and Juju clusters

MAAS implements a system of tags based on the physical properties of the nodes. The MAAS documentation on tags discusses this, mostly from the viewpoint of using existing hardware tags with the description option for –constraints. 

New tags can also be created manually to make it easier to deploy and manage MAAS and Juju clusters.    

For example if you want to bootstrap Juju on a MAAS cluster and force the bootstrap node to be on a specific machine, you could tag the node first, then bootstrap using the tag as a constraint.

$ juju bootstrap --constraints "tags=my-juju-bootstrap-node" –debug

Note that once you've set a tag constraint like this, following juju commands will attempt to use the constraint until you cancel it:

$ juju set-constraints "tags="

Another use of tags is to mark several nodes with the same tag and then deploy to only those nodes:

$ juju deploy mysql –constraints "tags=my-juju-Dell-nodes" --debug

Login to the MAAS Command Line Interface

Before you can use these commands, you must log into the MAAS region server:

$ maas login <profile-name> <host-url> <apikey>
  • <profile-name> can be anything you want, normally this is "maas"
  • <host-url> is the URL of the MAAS regional controller, plus the api and version (i.e. https://192.168.0.2/MAAS/api/1.0).
  • <apikey> is the MAAS api or oauth key created when the MAAS regional controller was built.

Refer to https://maas.io/docs/This hyperlink is taking you to a website outside of Dell Technologies. for details.

When done, to log out of the MAAS cli environment, run

$ maas logout maas

Creating Tags using the "description" option

As discussed in the MAAS documentation on tags, tags can be created and assigned using XPath Expressions, based on the "lshw" information (formatted as XML) associated with the node.   You can access this information at the bottom of each node webpage by clicking on the "Show discovered details" link under "Raw discovery data".   Part of the "lshw" information for one of my nodes follows:

...

<lshw:node id="t410" claimed="true" class="system" handle="DMI:0100">
<lshw:description>System</lshw:description>
<lshw:product>PowerEdge T410 ()</lshw:product>
<lshw:vendor>Dell Inc.</lshw:vendor>
<lshw:serial>RHXT410</lshw:serial>
<lshw:width units="bits">64</lshw:width>
<lshw:configuration>
<lshw:setting id="boot" value="normal"/>
<lshw:setting id="chassis" value="server"/>
<lshw:setting id="uuid" value="44454C4C-4800-1058-8054-D2C04F343130"/>
</lshw:configuration>
<lshw:capabilities>
...

To add more descriptive tags to nodes in the system, you might execute:

$ maas maas tags new name="Dell_Machine" definition='//node[@class="system"]/vendor = "Dell Inc."'
$ maas maas tags new name="Intel_Machine" definition='//node[@class="system"]/vendor = "Intel Corp."'
$ maas maas tags new name="Virtual_Machine" definition='//node[@class="system"]/vendor = "QEMU"'
$ maas maas tags new name="Laptop" definition='//node[@class="system"]/description = "Laptop"'
$ maas maas tags new name="Rack_Mount" definition='//node[@class="system"]/description = "Rack Mount Chassis"'
$ maas maas tags new name="Mini_Tower" definition='//node[@class="system"]/description = "Mini Tower Computer"'
$ maas maas tags new name="System" definition='//node[@class="system"]/description = "System"'
$ maas maas tags new name="Desktop" definition='//node[@class="system"]/description = "Desktop Computer"'
$ maas maas tags new name="Blade" definition='//node[@class="system"]/description = "Multi-system"'
$ maas maas tags new name="Intel_CPU" definition='//node[@class="processor"]/vendor = "Intel Corp."'
$ maas maas tags new name="AMD_CPU" definition='//node[@class="processor"]/vendor = "Advanced Micro Devices [AMD]"'
$ maas maas tags new name="64bit" definition='//node[@class="system"]/width="64"'
$ maas maas tags new name="32bit" definition='//node[@class="system"]/width="32"'

These will tag compliant nodes with the tags Dell_Machine, Intel_Machine, Virtual_Machine, Rack_Mount, System, Desktop, Laptop, Rack_Mount, Multi-system, 64bit, and/or 32bit, and are also applied to any nodes that are added later on.

Creating Tags Manually

A new raw tag is created with the MAAS cli command

$ maas <profile> tag new name="<tag-name>" [comment="<comment>"]
  • <profile> is the profile name that was set up with the login command, usually "maas"
  • <tag-name> is the name of the tag
  • <comment> is optional but a good idea.

Note that we are not using the description option here.   So:

$ maas maas tag new name="my-juju-node" comment="my new juju node"

This tag can be manually assigned to one or more nodes in the system.

Assigning Tags

To assign a tag to a node or nodes,  run the command:

$ maas <profile> tag update-nodes <raw-tag-name> add="<system-id>"
  • <profile> is the profile name set up during login
  • <raw-tag-name> is the name of the previously created tag
  • <system-id> is the system id of the node.

<system id>?  What's that?

How do you find the system id of a node?   One way is to list the node information and pick it out of the struct.  The maas cli command

$ maas <profile> nodes list
  • <profile> is the profile name set up during login

will dump out a JSON-formatted object (list of structs) containing all the information about the nodes.  For example:

$ maas maas nodes list

[
{
"status": 4,
"macaddress_set": [
{
"resource_uri": "/MAAS/api/1.0/nodes/node-2349c038-d792-11e3-8df4-0c54a5f0ce34/macs/bc%3A30%3A5b%3Ae3%3A21%3A15/",
"mac_address": "bc:30:5b:e3:21:15"
}
],
"hostname": "T110ii.maas",
"zone": {
"resource_uri": "/MAAS/api/1.0/zones/default/",
"name": "default",
"description": ""
},
"routers": [],
"netboot": true,
"cpu_count": 8,
"storage": 239825,
"owner": null,
"system_id": "node-2349c038-d792-11e3-8df4-0c54a5f0ce34",
"architecture": "amd64/generic",
"memory": 8192,
"power_type": "ipmi",
"tag_names": [
"use-fastpath-installer",
"my-juju-boostrap-node"
],
"ip_addresses": [
"192.168.0.53"
],
"resource_uri": "/MAAS/api/1.0/nodes/node-2349c038-d792-11e3-8df4-0c54a5f0ce34/"
},
]

Decoding the output

The first node in the list has a "hostname" attribute of "T110ii.maas". We are also interested in the system-id attribute for this node: "system_id": "node-2349c038-d792-11e3-8df4-0c54a5f0ce34"

We can now assign the new tag to this node:

$ maas maas tag update-nodes my-juju-bootstap-node add=node-2349c038-d792-11e3-8df4-0c54a5f0ce34

The "tag-names" attribute in Figure 1 lists all the tags assigned to this node, including the new one.

Scripts to help you add tags

Options:

  • --login : login before assigning the tags to the nodes. This option also requires
    • –oauth : the api / oauth key used to login above and possibly, depending on your setup,
    • –host_url : host URL used to login above
    • –profile : profile name used to login above
  • --remove_tags : remove the tags that were assigned earlier by this script.
  • --add_tags: add a tag to each node based on its name

References

Command Line Interface MAAS 1.6 Documentation:

https://maas.io/docs/maas-cliThis hyperlink is taking you to a website outside of Dell Technologies.

Juju Documentation (Constraints) 

https://juju.ubuntu.com/docs/charms-constraints.htmlThis hyperlink is taking you to a website outside of Dell Technologies.

https://juju.ubuntu.com/docs/reference-constraints.htmlThis hyperlink is taking you to a website outside of Dell Technologies.

Cause

-

Resolution

-

Affected Products

Ubuntu Server LTS
Article Properties
Article Number: 000129999
Article Type: Solution
Last Modified: 23 Jul 2024
Version:  4
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.