Build Linux VMs with additional Filesystems using VCF Automation

In our last blog we discussed how to build Windows VMs with additional Drives. In this blog we'll detail how to build Linux VMs with additional Filesystems. All screenshots here are from VCF Automation 8.18.8, but could be done in VCFA 9.x VM Apps as well. Let's go!
We'll need similar VCFA constructs:
Blueprint
vRO Workflow
Subscription
Blueprint Inputs Snippet
# ---------------- Disks ----------------
root_disk_gb:
type: integer
title: Root Disk Size (GB)
description: Boot disk (/). Must be at least the largest Linux template disk; it can only grow.
default: 50 # <-- set default + minimum to your LARGEST Linux template boot disk
minimum: 50
maximum: 500
extra_disks:
type: array
title: Additional Filesystems
description: Add one row per filesystem. Each mount point must be unique, e.g. /data, /app, /var/log/app
minItems: 0
maxItems: 10
items:
type: object
properties:
mountPoint:
type: string
title: Mount Point
default: /data
pattern: ^/[A-Za-z0-9._/-]+$
sizeGB:
type: integer
title: Size (GB)
default: 50
minimum: 1
maximum: 2048
fsType:
type: string
title: Filesystem
default: xfs
enum:
- xfs
- ext4
# ----------------------------------------
As you can see I'm asking the user how big they'd like the boot disk (/) to be. I'm also asking what additional Filesystems to create, beyond what will be deployed by the Image/Template. Feel free to adjust minimum/maximum sizes and Filesystem Types if you'd like. You can get the Blueprint here if you want it.
Blueprint Resources Snippet
# One VMDK per row in "Additional Filesystems" -> <vm>-disk1, -disk2, ...
Cloud_Volume_1:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${length(input.extra_disks)}
capacityGb: ${input.extra_disks[count.index].sizeGB}
name: ${input.vm_display_name + '-disk' + to_string(count.index + 1)}
provisioningType: thin
Cloud_vSphere_Machine_1:
type: Cloud.vSphere.Machine
properties:
image: ${input.os}
cpuCount: ${input.vcpuCount}
totalMemoryMB: ${input.totalMemoryMB}
name: ${input.vm_display_name}
hostname: ${input.vm_dns_name}
misc_notes: ${input.misc_notes}
owner: ${input.owner}
description: ${input.description}
category: ${input.category}
customizationSpec: ${input.customizationspec}
# / - resize the boot disk
storage:
bootDiskCapacityInGB: ${input.root_disk_gb}
# Additional filesystems - attach the new volumes
attachedDisks: ${map_to_object(resource.Cloud_Volume_1[*].id, "source")}
# Passed to the vRO post-provision workflow (mount points + filesystem types)
extraDisks: ${input.extra_disks}
networks:
- network: ${resource.Cloud_Network_1.id}
assignment: static
address: ${input.ip}
This is where I re-size the boot disk (/) and build the additional disks.
Now, like with the Windows Blueprint, if you were to deploy a Linux VM using this Blueprint it would work, you'd have any additional disks configured, but you wouldn't see the Filesystems.
We need a vRO Workflow to format/mount those Fileystems. This vRO Workflow is similar to the one we used for Windows VMs, but different. If you'd like to use it you can get it here. Note: the root credentials being used in the vRO Workflow match those being set by the Customization Specification being called by the Blueprint. If you're intersted in how to set Linux root password using Customization Specifications see this blog.
Next we need a Subscription calling this vRO Workflow, mine looks like this.

Notice the Subscription is against the Compute post provision Event and it calls the vRO Workflow I just created. Let's go request a VM.
As you can see, I've wrapped my Blueprint in a Custom Form, if you'd like the Custom Form you can get it here.
Once the deployment finishes I SSH into my new VM and have my additional Filesystems.

I hope this was helpful, enjoy!



Comments