vRealize Automation – Add additional disk using SovLabs Property Toolkit

SovLabs has been adding some great new features to their Property toolkit module:

  • v2019.14.0
    • Dynamically set and assign vRA Network Profile Names to VMs in a blueprint with our SovLabs Property Toolkit module for vRA 7.5 and vRA 7.6.  Read more here
  • v2019.16.0
    • Dynamically add additional vRA Disks to VMs in a blueprint with our SovLabs Property Toolkit module for vRA 7.5 and vRA 7.6.

Today we are looking at their new feature to dynamically add additional vRA disks, using the Property Toolkit module, which is a widely discussed topic on blogs and VMware’s community forum.

There are of course multiple ways to achieve this, for instance adding disks to the vSphere machine on the request form, however this method is very basic and does not provide a lot of flexibility.

wordpress-0028.jpg

Other customer would resort to creating custom forms with data grids with vRO actions to implement this.

SovLabs Property Toolkit module uses custom properties and can add up to 15 disks and makes use of the approval lifecycle of VM provisioning to assign disks prior to MachineRequested EBS.

Prerequisites:

  • vRealize Automation 7.5 or newer
  • SovLabs Plug-in Version 2019.16.0 or newer
  • Approval Policy Type: Service Catalog – Catalog Item Request – Virtual Machine
  • vRA blueprint with Cloned Machine Build type
    • Make sure to correctly set the total capacity/maximum storage value that can support the disks to be added
  • vRA login as Tenant Administrator or Approval Administrator and entitled to SovLabs Modules.

Configure the required approval policy

  • Login to vRA
  • Select the vRA Catalog and search for “Manage Property Toolkit”
  • wordpress-0029
  • Click Request on “Manage Property Toolkit Approval Policies – SovLabs Module”
    • wordpress-0030
    • For Action select Create
    • For Approval select “Service Catalog – Catalog Item Request – Virtual Machine
    • Enter Policy name
      • For instance “Disk Add Policy”
    • Optionally enter a description of the policy
    • Click Submit
    • This will now automatically create an approval policy in vRA
    • wordpress-0031.jpg
  • Add the newly create approval policy to your vRA entitlements
    • In vRA go to Administration tab -> Catalog Management -> Entitlements
    • Select the entitlement for your specific business group
    • Select the Items & Approvals tab
    • wordpress-0032
    • Under Entitled Items, click the green plus button
    • Select your blueprint and under Apply this policy to selected item, firstly click on “Show all”, and select the newly create disk add policy
    • Click OK
    • Another option to associate the disk add policy to all virtual machines under entitled items is to select the item name “Virtual Machine Component”.
    • wordpress-0033.jpg

Configure the Blueprint

There are a lot of design options available which I will review shortly, but for my example I am just adding custom properties to my blueprint.

  • Go to Design ->  Select the blueprint
  • Select the vSphere Machine
  • Go to Properties tab
  • Select Custom Properties
  • Add the SovLabs custom properties
    • SovLabs_VM_Disk1-Letter
      • For a Windows OS this value will be the drive letter like  “D”
      • For a Linux OS this value will be the mount point like “\mnt\disk1”
    • SovLabs_VM_Disk1-Size
      • Size of the disk
    • wordpress-0035
    • There are a lot of other SovLabs custom properties for disk options that can be added. Review the list here

Test the approval policy and disk addition

  • Go to Catalog Items >  Select the catalog item
    • The Business Group needs to match the BG where the approval policy was added to the entitlement
  • Click Request
  • Select the vSphere Machine and enter values for the Property below
    • SovLabs_VM_Disk1-Letter = F
    • SovLabs_VM_Disk1-Size = 11
  • Click Submit
  • Once the provisioning completed successfully, lets verify the new disks are added
  • Go to Deployments tab and select the deployed catalog item
  • Under component tab select the VM
  • Go to the Storage tab.
  • Verify the additional disk appear on the VM.
  • wordpress-0036.jpg
  • You can also verify the same from vCenter Server.

 

But wait, that’s not it! What about the rest?

Now as most of us know this only solves half of the puzzle and the added disk still has to initialized, partitioned and formatted to be available to the user for consumption.  We definitely cannot provide the solutions in the current state!

There are 2 solutions which I will explore in more detail here.

vRealize Automation guest agent:

The most common solution to this problem is to make use of the guest agent (gugent), which requires an agent to be installed on the templates used for cloning.  These links provide the steps to perform the installation for Linux and Windows.   (I recommend using the provided Powershell script)

Another requirement is to add 2 custom properties to each of your vRA blueprints.

  • VirtualMachine.Admin.UseGuestAgent = true
  • VirtualMachine.Customize.WaitComplete = true

The agent solution works really well for both Windows and Linux OS.

  • For Windows OS:
    • It will initialize the disk, add the drive letter, label and format it.
    • wordpress-0037.jpg
  • For Linux OS
    • It will partition a disk as a standard Linux partition and add the specified mount points:
    • linux
    • linux2

However what if your Linux team uses LVM? As an example, what if I need to extend an existing volume group with the added disk, and then create a new logical volume?  This is not really possible with gugent unless you want to update the content of the gugent scripts.  This action I do not recommend and is probably not supported by VMware.

SovLabs Lifecycle Toolkit

There are other options available to achieve the same outcome for instance using gugent to run script locally on the provisioned host, or use SovLabs Lifecycle Toolkit to SSH to an Ansible control machine and run Ansible scripts.  For this blog I am using LCT to run the script on the provisioned Linux host.

There a quite a few steps so lets get started on SovLabs vRA CAFE Endpoint setup

  1. Click the Catalog tab
  2. Click Request on “Add SovLabs vRA CAFE Endpoint”
  3. Screen Shot 2017-04-20 at 8.44.47 AM.png
  4. Enter Configuration label
    • Only AlphaNumeric characters, no spaces or special characters except: - and _
  5. Version and Hostname are  auto-generated and based on querying vRA CAFE, verify that the information is correct
  6. If you have not configure this endpoint module then you need to create credentials.
  7. Click Submit

Add the Lifecycle EBS:

  1. Click the Catalog tab
  2. Click Request on “Manage Lifecycle EBS”
  3. For Action select Create
  4. For Lifecycle select “Machine Provisioned”
  5. Set the priority to run the EBS
    1. To select the correct value you can can review the Current Machine Provisioned EBS priority already set.
  6. wordpress-0038

 

Add lifecycle script definition: (This is where all the magic happens)

  1. Click the Catalog tab
  2. Click Request on “Add Lifecycle Script definition”
  3. Enter Configuration label
    • Only AlphaNumeric characters, no spaces or special characters except: - and _
  4. For Type select Provisioned Node
  5. For Lifecycle State select “Machine Provisioned”
  6. For OS Family select unix
  7. For Connection type select vmware-tools
  8. For vCenter Endpoint select one that was already create.
    1. If you review my DRS blog here for reference
  9. Create credentials for your deployed Linux OS
  10. wordpress-0041
  11. Most of the following settings you can leave the defaults
  12. Add the script that you want to run on the provisioned Linux host
    • echo -e "n\np\n1\n\n\nt\n8e\nw" | fdisk /dev/sdb
      pvcreate /dev/sdb
      vgextend centos /dev/sdb
      lvcreate -L {{SovLabs_VM_Disk1-Size}}G -n {{SovLabs_VM_Disk1-Letter | slice: 1, SovLabs_VM_Disk1-Letter.size | replace: "/", "_"}} centos
      mkfs.ext4 /dev/centos/{{SovLabs_VM_Disk1-Letter | slice: 1, SovLabs_VM_Disk1-Letter.size | replace: "/", "_"}}
      mkdir {{SovLabs_VM_Disk1-Letter}}
      mount /dev/centos/{{SovLabs_VM_Disk1-Letter | slice: 1, SovLabs_VM_Disk1-Letter.size | replace: "/", "_"}} {{SovLabs_VM_Disk1-Letter}}
      exit 0
    • As you can see using the custom properties created in vRA to input the size as well as the mount point
    • I am using the mount point information to derive the logical volume by removing the first character (“/”), and changing the forward slashes to underscore characters.
    • wordpress-0043.jpg
    • You can also specify a success criteria for the workflow which is very helpful.

 

Other design ideas

  • By using the Property Toolkit Template Engine logic to define your Lifecycle Toolkit profile you have the ability to run different disk configuration for each deployment. For example:
    • Instead of extending the Volume group, create a new one based on OS and/or the application selected.
    • Perhaps different mount points are required based on specific app selection
    • “SovLabs_LCProfile = add_disk_{{OS_selection}}_{{app_selection}}”
  • With the vRA connector you can also requests the disk from ServiceNow
    • wordpress-0042
  • These new add disk features for Property Toolkit does not just provide customization of the OS, but also how the disks are added to vCenter Server:
    • SovLabs_VM_Disk#-Storage
      • Specify the Disk’s vCenter Server datastore
    • SovLabs_VM_Disk#-StorageReservationPolicy
      • Specify Storage Reservation Policy Name
    • SovLabs_VM_Disk#-StorageReservationPolicyMode
      • Specify Storage Reservation Policy Mode
  • For multiple disk you can change the script to accommodate for this
    • for x in {b..d}; do echo -e “n\np\n\n\n\nt\n8e\nw\n” | fdisk /dev/sd”$x”; done

 

There are many ways to approach this, but with SovLabs LCT and Property Toolkit modules it sure does simplify the configuration and provide lost of flexibility.

Links:

https://support.sovlabs.com/support/solutions/articles/6000227453-sovlabs-property-toolkit-add-disks-approval-policy  (lots of valuable information here to get started)

http://docs.sovlabs.com/latest/vRA/7.5/modules/vra-toolkits/property-toolkit/vra-additional-disks/

http://docs.sovlabs.com/latest/vRA/7.5/modules/vra-toolkits/lifecycle-toolkit/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s