vRA custom host name using Orchestrator and Event Broker
In a recent POC the customer had a special use case which I tackled singing vRealize Orchestrator and the Event Broker Service.
So, what was the use case?
Roll out a new Windows vSphere virtual machine using a custom hostname based on the machine type (Development=’dev0001‘, Test=’tst0001′, Production=’prd0001′, etc.). The hostname has to be the next available Computer Account in the Active Directory.
For example: a user requests a new Production machine and ‘prd1021′ is the latest Computer Account in the Active Directory, the new virtual machine will get hostname ‘prd1022′.
To accomplish this, I created a vRO workflow which will be used during vRA deployment of the VM triggered by the Event Broker.
Custom host name vRO workflow
The vRO workflow makes use of a custom property vm.name.convention which needs to be added to vRA and can be used during request. Also an Active Directory server has to be registered with vRO.
The workflow performers the following tasks:
- Get VM property information from vRA;
- Get the vm.name.convention custom property;
- Uses the custom property to search the Active Directory for the latest Computer Account;
- Determines the new hostname for the VM (latest Computer Account +1);
- Updates the initial VM hostname property used by vRA with the new hostname.
Download the workflow here and rename it to ‘EBS Host Rename.workflow’
Note: The script to search the Active Directory splits the hostname in a prefix and number. These have a fixed size in the script. In my case the prefix is 5 characters long and the number is 4 digits (total of 9). This can be changed in the script if needed.
var newComputerNameSuffix = lastComputerName.substring(5,9)
var MachinePrefix = lastComputerName.substring(0,5)
var SuffixNumber = Number(newComputerNameSuffix)
var nextNumber = SuffixNumber + 1
Configure the Event Broker and create a blueprint
Start the vRO client and import the Custom Hostname workflow.
Edit the workflow and add your vRA IaaS- and Active Directory server to the Attributes.
Save and Close the workflow.
Login to vRA and add a new custom property definition vm.name.convention. Make it available as a dropdown value during request. Under Predefined values you can add your VM naming convention related to machine type.
Create a new blueprint and give it a Name.
In the Properties tab add the Custom Property vm.name.convention and select Show in Request.
Drag and drop a Network component and a vSphere Machine on the canvas. Edit the properties of the components according to your environment. If you want the machine to be automatically joined with the Domain, use/create a vSphere Customization specification which takes care of this.
Save the Blueprint and publish it.
Create a new Event Subscription to trigger the Custom Hostname workflow during request. Select Machine provisioning Topic.
Add the following Conditions:
- Blueprint name -> Equals -> ..yourblueprintname..
- Lifecycle State Name -> Equals -> VMPSMasterWorkflow32.Requested
- Lifecycle State Phase -> Equals -> EVENT
Select the Custom Hostname workflow.
Finish the Subscription and publish it.
Testing the workflow
First check your Active Directory for existing Computers Accounts.
Go to the Catalog and request the Blueprint using the Custom Hostname.
In my case I select Machine type Productie which determines the VM hostname prefix to be ‘wpzkh’.
The latest available Computer Account with prefix wpzkh is wpzkh1005. The new VM hostname provisioned by vRA should be ‘wpzkh1006‘. So let’s check this.
The workflow is being triggered. So the Event Subscription is working correctly.
The new Machine name is being updated by vRO and passed on to vRA. Under Managed Machines ‘wpzkh1006′ is visible.
Note: Thanks to Adam Bohle for helping me out with the vRO piece.
Dimitri is a CMP Specialist SE with VMware and therefor responsible for positioning and supporting vRealize Automation, Operations, Business and Code Stream at customers and partners.
He is a 15 year IT veteran who started as a system administrator and grew to be a senior infrastructure consultant at a large dutch hospital. He has a broad infrastructure, virtualization and VDI background and is experienced in pre-sales, consultancy, design and implementation of complex infrastructures.
Other articles in the series vRealize Automation:
- Setup provisioning of vCloud Air workloads
- Setup a vCloud Air Endpoint in vRealize Automation
- Setup Postgres database high availability for vRealize Automation
- Setup vRealize Automation Cost profiles & currency
- Speed up vRealize Automation life cycle updates
- Configure vRealize Automation not to delete virtual machines
- Track infrastructure changes with vRealize Automation Data Collection
- MS SQL high availability support for vRealize Automation
- Setup the vRealize Automation prerequisites for IaaS
- vRealize Automation: How to …
- Downgrade the vRealize Automation license
- vRealize Automation 7 – New Architecture & Installation
- vRealize Automation 7 – Improved Authentication
- vRealize Automation 7 – Converged Blueprints
- vRealize Automation 7 – LifeCycle Extensibility
- How to transfer vRealize Automation payload to Orchestrator
- Automation is not difficult with vRealize Automation 7
- vRA custom host name using Orchestrator and Event Broker
- How to deliver Database-as-a-Service with vRealize Automation
- Prepare Windows for vRA software deployment
- Create a new database user using vRealize Automation XaaS
- How to transfer vRealize Automation payload to Orchestrator by Erik Scholten
- vRealize Automation 7 – LifeCycle Extensibility by Erik Scholten
- VMware releases vRealize Orchestrator plug-in for vSphere… by Erik Scholten
- How to deliver Database-as-a-Service with vRealize… by Erik Scholten
- Speed up vRealize Automation life cycle updates by Erik Scholten