This article was written Mark Wenning, Canonical Field Engineer.
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
Before you can use these commands, you must log into the MAAS region server:
$ maas login <profile-name> <host-url> <apikey>
Refer to https://maas.io/docs/ for details.
When done, to log out of the MAAS cli environment, run
$ maas logout maas
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.
A new raw tag is created with the MAAS cli command
$ maas <profile> tag new name="<tag-name>" [comment="<comment>"]
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.
To assign a tag to a node or nodes, run the command:
$ maas <profile> tag update-nodes <raw-tag-name> add="<system-id>"
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
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/" }, ]
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.
Options:
Command Line Interface MAAS 1.6 Documentation:
Juju Documentation (Constraints)