Advice on User Scripts for Creating RAID Volumes during commissioning

Apologies TL;DR

I’m wondering if anyone can weigh in on this and let me know if I’m on the right track or if there’s a better way to do this.

I’ve gotten a fresh bunch of servers with fresh hard drives in them. When the nodes get enlisted they turn up ‘new’ without any storage, simply because no Logical Volume(s) has been created yet.
I could simply create the RAID volumes on the WEBcli before the PXE boot, but I’m lazy and doing this at scale is not really feasible (cattle vs pets)

So I (plagiarised) came up with this script which installs the MegaRAID cli and continues to do a fancy ‘for loop’ and creates standalone Logical Drives for each disk in the machine which the node sees on next boot as /dev/sda, /dev/sdb and dev/sdc.

#Script hacked up by Sean Shuping for MAAS enrollment
#Download and install LSI MegaRAID Megacli
#Install alien, unzip and libncurses5 to convert rpm package to deb
if lspci | grep -q MegaRAID
echo "MegaRAID Controller found will check for volumes"
sudo apt update
sudo apt -y install alien unzip libncurses5
unzip *Mega*.zip
sudo alien -k --scripts Linux/MegaCli-8.07.14-1.noarch.rpm
sudo dpkg -i *megacli*.deb
 if sudo /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -a0 | grep -q "No Virtual Drive Configured"
 echo "Will continue to create Volumes"
	 DEVICEID=$(sudo /opt/MegaRAID/MegaCli/MegaCli64 -EncInfo -aALL | grep "Device ID" | awk -F: '{print $2}')
	 for SLOTNUMBER in $(sudo /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL  | grep "Slot Number" | awk -F: '{print $2}')
	 sudo /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0 [$DEVICEID:$SLOTNUMBER] -a0 
	 echo " At least one Volume Found, Skipping"
echo "MegaRAID Controller not found, nothing to see here"; exit

The issue though is that my user script gets executed last, and as a result I need to commission the nodes twice, because the SMARTctl validate ‘fails’ the first time as there’s no volume to check (yet). On the second run of commissioning, the nodes ‘pass’ and move to a ready state because the Volume was created at the end of the first round of commissioning.

Is there a way to bump the order of Commissioning Scripts or am I going about this the wrong way.

I also found that when composing Virtual Machines on KVM pods those guests were automatically running my user script, so I had to modify the script logic which checks to see if there is in fact a RAID card present, if not it gracefully exits so that KVM guests wouldn’t fail their commissioning.

I renamed with script from to

This floats the commissioning script higher in the execution order and now runs before all the native MAAS commissioning scripts.
When a new node is provisioned, the storage gets created and all the validation are successful.

1 Like

brilliant work, @dvnt! kudos.

1 Like

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