Enabling custom scripts to run during enlistment using "tags: enlisting"

I didn’t find this in the docs anywhere:

To make a custom commissioning script run during enlistment, add “tags: enlisting” to its metadata.

I just got this script working to allow a fresh Supermicro node with its IPMI LAN set from the factory as “Dedicated” to be set to “Shared” so that it can pick up an IP address from DHCP and be successfully commissioned with a single ethernet cable plugged in:

#!/usr/bin/env python3
#
# 00-supermicro-ipmi-shared-v02 - Set Supermicro IPMI LAN mode to shared
#
# Author: Andrew Klaassen <andrew.klaassen@boatrocker.com>
#
# --- Start MAAS 1.0 script metadata ---
# name: 00-supermicro-ipmi-shared-v02
# title: Set Supermicro IPMI LAN mode to shared
# description: Set Supermicro IPMI LAN mode to shared
# tags: enlisting
# script_type: commissioning
# for_hardware: system_vendor:Supermicro
# packages:
#   apt:
#     - ipmitool
# --- End MAAS 1.0 script metadata --

import subprocess

COMMAND_TIMEOUT = 60 * 3


def set_supermicro_ipmi_lan_shared():

    print("INFO: Loading IPMI kernel modules...")
    for module in [
        "ipmi_msghandler",
        "ipmi_devintf",
        "ipmi_si",
        "ipmi_ssif",
    ]:
        # The IPMI modules will fail to load if loaded on unsupported
        # hardware.
        try:
            subprocess.run(["sudo", "-E", "modprobe", module], timeout=COMMAND_TIMEOUT)
        except subprocess.TimeoutExpired:
            pass
    try:
        subprocess.run(["sudo", "-E", "udevadm", "settle"], timeout=COMMAND_TIMEOUT)
    except subprocess.TimeoutExpired:
        pass

    print("INFO: Setting Supermicro IPMI LAN to shared mode...")
    cmd = ["sudo", "-E", "ipmitool", "raw", "0x30", "0x70", "0x0c", "1", "1"]
    output = subprocess.check_output(cmd, timeout=COMMAND_TIMEOUT).decode()
    print('INFO: ipmitool returned: "%s"' % output)


if __name__ == "__main__":
    set_supermicro_ipmi_lan_shared()

The only places I can see this mentioned are in this bug report:

Bug #2024473 “maas 3.3 doesn’t run custom commissioning scripts …” : Bugs : MAAS (launchpad.net)

A correction to my script: It looks like “for_hardware” doesn’t work during enlisting, so I ended up getting rid of that and using “dmidecode --string system-manufacturer” as part of the script instead.