How to add Windows Server Drives to VMware Aria Automation Cloud Templates.
I want to create new Windows Servers in VMware Aria Automation that will be production ready when the server build process is complete. One item when building new Windows Servers is adding drives. I want a way to add additional drives and have the drive be online and formatted properly. Non SQL Windows Servers will have data drives formatted with 4k allocation unit size and Windows SQL Servers will have the data drives formatted with 64k allocation unit size. VMware Aria Automation provides a way to add drives OOTB (Out of the Box) but does not automatically format the drives. That is why I use a Salt state in my example. I use the salt state to bring the new drive online and format. This Blog post shows one way to accomplish these tasks. I always say, with automation there a 100 ways to do the same process. Hopefully this Blog gives you some ideas and options.
Use Case
Add Cloud Agnostic Volumes to a VMware Aria Automation Cloud Template.
To make New Windows Server Builds consistent I show the drives that are available on the Catalog Item Custom Form. You don’t need to add any additional drives. Keep the drive sizes at the default size of “0” and the drives DO NOT get created.
At the end of the new server build I want the new Windows Server drives to be online and formatted properly. Be production ready!
Steps to complete the process:
Automated Salt minion installation. See the Blog Post I wrote that completes this step. Click Here
Add grains data about the drives to minion when the minion installation completes. See example yaml code.
Run a state file when the minion installation completes that brings the new drive online and formats the drive so that it is ready to use immediately. See example yaml code.
Requirements:
This blog was created using VMware Aria Automation and VMware Aria Automation Config version 8.11.0 (Salt version 3005.1). The process may vary for different versions of VMware Aria Automation and Salt.
Cloud Template | Windows 2019 Server:
There are (3) Cloud Agnostic Volumes on the Cloud Template for my use case. You can have as many as you want for your environment.
The SaltStack Config Resource is added to the Cloud Template.
Click to see Larger Image of Screen Shot
VMware Aria Automation Cloud Template file:
Click to see Larger Image of Screen Shot
Key elements to review in the yaml code:
The yaml code includes grains that saves the drive information. These values are based on input from the Catalog custom form.
the yaml code includes stateFiles to run.
If the drive size input specified is equal to “0” then the drive count will be “0”. Drive will NOT be created.
formatVersion:1inputs:CustomizationSpec:type:stringdescription:Customization Specificationdefault:W2K19title:CustomizationSpecVMName:type:stringtitle:VM NameminLength:1maxLength:15default:DBH-194IP:type:stringdefault:192.168.110.194EDrive:type:integertitle:E-Drivedefault:0description:Enter 0 to disable the disk and not createLDrive:type:integertitle:L-Drivedefault:0description:Enter 0 to disable the disk and not createTDrive:type:integertitle:T-Drivedefault:0description:Enter 0 to disable the disk and not createSQL:type:stringtitle:SQLdescription:Selecting SQL will format all DATA drives with 64k allocation.default:'False'enum:- 'True'- 'False'resources:Network:type:Cloud.Networkproperties:networkType:existingconstraints:- tag:network:VMsVirtual_Machine:type:Cloud.Machineproperties:image:W2K19flavor:mediumcustomizationSpec:${input.CustomizationSpec}name:${input.VMName}remoteAccess:authentication:usernamePasswordusername:administratorpassword:VMware1!networks:- network:${resource.Network.id}assignment:staticaddress:${input.IP}attachedDisks:${map_to_object(resource.Cloud_Volume_E[*].id + resource.Cloud_Volume_L[*].id + resource.Cloud_Volume_T[*].id , "source")}edrivesize:${input.EDrive}ldrivesize:${input.LDrive}tdrivesize:${input.TDrive}sql:${input.SQL}# - VMware Max SCSI Controllers is 4# - VMware Max Unit per SCSI Controllers is 15Cloud_Volume_E:type:Cloud.Volumeproperties:capacityGb:${input.EDrive}count:'${input.EDrive == 0 ? 0 : 1 }'SCSIController:SCSI_Controller_1unitNumber:0provisioningType:thinCloud_Volume_L:type:Cloud.Volumeproperties:capacityGb:${input.LDrive}count:'${input.LDrive == 0 ? 0 : 1 }'SCSIController:SCSI_Controller_1unitNumber:1provisioningType:thinCloud_Volume_T:type:Cloud.Volumeproperties:capacityGb:${input.TDrive}count:'${input.TDrive == 0 ? 0 : 1 }'SCSIController:SCSI_Controller_1unitNumber:2provisioningType:thinCloud_SaltStack_1:type:Cloud.SaltStackproperties:hosts:- ${resource.Virtual_Machine.id}masterId:saltstack_enterprise_installerstateFiles:- /vcrocs/windows-server-services.sls- /vcrocs/windows-server-new-drives.slssaltEnvironment:baseadditionalMinionParams:grains:vCROCS_Roles:- webserver- databasevCROCS_Drive_E_Size:- ${input.EDrive}vCROCS_Drive_L_Size:- ${input.LDrive}vCROCS_Drive_T_Size:- ${input.TDrive}vCROCS_SQL:- ${input.SQL}
Service Broker Catalog item:
Show the (3) drives that are available as a Standard Windows Server Build.
To create the drives is an option. Make drive size a “0” (default Value) and the drive will NOT be created.
Select SQL “True” will make the data drives be formatted with 64k allocation unit size, “false” will be 4k allocation unit size.
Click to see Larger Image of Screen Shot
Completed Windows Server Deployment:
Shows which salt states were used with the deployment.
You can view the grains data that was added to the minion.
Click to see Larger Image of Screen Shot
VMware Aria Automation Config State file:
Screen shot shows the state file in SaltTack Config File Server.
Click to see Larger Image of Screen Shot
The state file is very simple. Tells the minion which PowerShell script to run.
PowerShell Script to online and format new drives:
The PowerShell file is saved within the VMware Aria Automation Config file server.
Click to see Larger Image of Screen Shot
The PowerShell script gets the grain data and stores it as variables.
If the drive letter capacity is greater than “0” it will execute.
Script will only run on new drives in offline mode as a safety feature. Will not do anything with existing online drives. If state is run by accident after server is in production nothing will change.
Script uses the grain data SQL to determine how to format the drives. If grains value SQL is equal to “True” the it will use 64k allocation unit size, otherwise it uses 4k allocation unit size.
# ----- [ Get minion data ] -----$eDrive=salt-callgrains.getvCROCS_Drive_E_Size--output=json|ConvertFrom-Json$eDrive=$eDrive.local$output='E-Drive: '+$eDriveWrite-Output$output$lDrive=salt-callgrains.getvCROCS_Drive_L_Size--output=json|ConvertFrom-Json$lDrive=$lDrive.local$output='L-Drive: '+$lDriveWrite-Output$output$tDrive=salt-callgrains.getvCROCS_Drive_T_Size--output=json|ConvertFrom-Json$tDrive=$tDrive.local$output='T-Drive: '+$tDriveWrite-Output$output$SQL=salt-callgrains.getvCROCS_SQL--output=json|ConvertFrom-Json$SQL=$SQL.local$output='SQL: '+$SQLWrite-Output$output# ----- [ Function to bring drive online and format ] -----functionset-driveOnline{param([parameter(mandatory=$true)][string]$driveLetter,[int]$diskNumber)$diskOnline=Get-Disk|Where-ObjectNumber-EQ$diskNumberif($diskOnline.OperationalStatus-eq'offline'){Get-Disk|Where-ObjectNumber-EQ$diskNumber|Set-Disk-IsOffline$False$disksize=Get-Disk-Number$diskNumber|Select-Objectsize$disksize=$disksize.size$disksize=$disksize/1073741824$output='Disk '+$diskNumber+' Size: '+$disksizeWrite-Output$outputif($disksize-gt0){Initialize-Disk$diskNumber-PartitionStyleGPT}# End ifNew-Partition-DiskNumber$diskNumber-UseMaximumSize-DriveLetter$driveLetterif($SQL-eq'True'){Format-Volume-DriveLetter$driveLetter-FileSystemNTFS-NewFileSystemLabel"SQL Data"-AllocationUnitSize65536-Confirm:$false}# End Ifelse{Format-Volume-DriveLetter$driveLetter-FileSystemNTFS-NewFileSystemLabel"APP Data"-AllocationUnitSize4096-Confirm:$false}# End Else$global:diskNumber++$output='Disk Number: '+$global:diskNumberWrite-Output$output}# end if offline}# end function$global:diskNumber=1$output='Disk Number: '+$global:diskNumberWrite-Output$outputif($eDrive-gt0){$driveLetter='E'$output='Drive Letter: '+$driveLetterWrite-Output$output# run functionset-driveOnline-driveLetter$driveLetter-diskNumber$global:diskNumber}# end ifif($lDrive-gt0){$driveLetter='L'$output='Drive Letter: '+$driveLetterWrite-Output$output# run functionset-driveOnline-driveLetter$driveLetter-diskNumber$global:diskNumber}# end ifif($tDrive-gt0){$driveLetter='T'$output='Drive Letter: '+$driveLetterWrite-Output$output# run functionset-driveOnline-driveLetter$driveLetter-diskNumber$global:diskNumber}# end if
This screen shot shows how the drives status will be in the Windows Server Disk Management when the New Server Build is Complete. No additional steps are required to start using the drives.
Click to see Larger Image of Screen Shot
This screen shot shows where the grains file is saved.
Click to see Larger Image of Screen Shot
This screen shot shows the grains file contents.
Click to see Larger Image of Screen Shot
Lessons Learned
Lessons Learned:
Saving information as grains data is a great way to save input data when creating new servers.
The combination of having Salt State files run PowerShell scripts is very powerful when creating new Windows Servers with VMware Aria Automation.
Info
When I write about VMware Aria Automation, I always say there are many ways to accomplish the same task. VMware Aria Automation Config is the same way. I am showing what I felt was important to see but every organization/environment will be different. There is no right or wrong way to use Salt. This is a GREAT Tool that is included with your VMware Aria Suite Advanced/Enterprise license. If you own the VMware Aria Suite, you own VMware Aria Automation Config.
VMware Aria Automation = vRealize Automation
VMware Aria Automation Config = SaltStack Config
If you found this Blog article useful and it helped you, Buy me a coffee to start my day.