How to enable Hardware synchronization for machines deployed with MAAS 2.x

Hey MAAStronauts!

In MAAS 3.x we have introduced the so called hardware synchronization feature.

You can also manually report hardware updates by following the steps in the How to update hardware information for a deployed machine section of this doc.

However, this will not work for machines that were last commissioned using MAAS 2.x. To summarize without delving into too much detail, when the machine runs the maas-run-scripts command, a zip file is downloaded from the controllers. This file contains several scripts, one of which is responsible for gathering hardware information.

The controller has internal logic to include only specific commissioning scripts: if a script has never been executed on a machine, it won’t be included in the zip file. In MAAS 3.x, we introduced a new script called 20-maas-03-machine-resources, which naturally wouldn’t have been run on machines commissioned with MAAS 2.x. This is why you’ll encounter an error if you attempt to run it on machines that were commissioned with version 2.x.

For this reason, the fix is actually to let MAAS think that the script was executed once.

For 3.2 environments, you can run the following query (replace the system_id accordingly):

INSERT INTO metadataserver_scriptresult
  (created, updated, status, script_name, script_id, script_set_id, parameters, suppressed, output, stdout, stderr, result)
VALUES
  (NOW(), NOW(), 2, '20-maas-03-machine-resources',
   (SELECT id FROM metadataserver_script WHERE name = '20-maas-03-machine-resources'),
   (SELECT current_commissioning_script_set_id FROM maasserver_node WHERE system_id = '<THE SYSTEM_ID>'),
   '{}', false, '', '', '', '');

for 3.3 and above:

INSERT INTO maasserver_scriptresult
  (created, updated, status, script_name, script_id, script_set_id, parameters, suppressed, output, stdout, stderr, result)
VALUES
  (NOW(), NOW(), 2, '20-maas-03-machine-resources',
   (SELECT id FROM maasserver_script WHERE name = '20-maas-03-machine-resources'),
   (SELECT current_commissioning_script_set_id FROM maasserver_node WHERE system_id = '<<<REPLACE WITH THE SYSTEM ID!>>>>'),
   '{}', false, '', '', '', '');

Here some screenshots.

2 Likes