Create Custom Names with vRealize Automation 8
In the latest version of vRealize Automation (vRA), version 8, when you create a new blueprint for deploying a Virtual Machine, you probably noticed once you deploy the Virtual Machine it gets a standard machine name something like Cloud_Machine_1-mcmxxx-xxxxxxxxxxxx. But most customers use their own standard name convention. So, which options are there available for vRA customers to create custom names to be compliant with their standards? In this blogpost I’ll explain three options in vRA 8 (and vRA Cloud) to create custom names for VMs.
Using Infrastructure as Code
The first option is to rename your Machine objects on the design canvas in vRA Cloud Assembly. For example, when you drag & drop a Machine onto the canvas it gets a standard name like Cloud_Machine_1. Changing this in for example vmguru_machine results in a VM named something like vmguru_machine-mcmxxx-xxxxxxxxxxxx.
Another option is to add the name property to the YAML code. In my case I will use vmguru_vm. The VM will now be named vmguru_vm-mcmxxx-xxxxxxxxxxxx.
Be aware that the name property will overrule the object naming!
Using Custom Properties and the Custom Naming option
As you saw above, renaming the Machine object or using the name property still resulted in a VM name ending with mcmxxx-xxxxxxxxxxxx.
What if you don’t want this? Or you want to use vRA (custom) properties to build your VM name in a dynamic way?
This can be done with Custom Properties and the Custom Naming feature on a per vRA Project basis.
In vRA Cloud Assembly select the Infrastructure tab. Under Configure click on Projects. Open your Project and then select the Provisioning tab.
Under Custom Properties you can define properties with a name and value that will be added to every request in this Project. For example, a Country or Site code, a Cost Center etc. etc.
Once you created your properties, go to Custom Naming. The template will define how your VM name will be generated. In the template you can use vRA Project-, Resource- and Endpoint Properties but also Username, User Email address and a Random number.
In my case my template looks like:
This will generate the following VM name:
Save your Project settings and deploy your blueprint.
Be aware once you created a Project Custom Naming template, this will overrule naming a Machine object in the YAML code! Even the third option described below!
Using an Action script
The third option for renaming your VM uses a different approach.
In vRA 8 (and vRA Cloud) there’s a new extensibility feature called Action Based Extensibility. ABX in short. Instead of using vRealize Orchestrator workflows, ABX leverages Function as a Service to directly run an action script created in Python or NodeJS. For example, to tag a VM or do an API call to another system or Public Cloud Provider. Support for Powershell scripts will be added shortly.
To trigger the action, vRA uses Subscriptions to define conditions when the action should run based on a lifecycle event in the Event Broker.
Let me show you how to do this.
In vRA Cloud Assembly select the Extensibility tab. Under Library click on Actions. Click New Action.
Enter a Name for the action and select your Project.
Click on Load Template and select Rename VM. Click Load.
In the left script pane, add [customProperties] in line 12 for the new_name inputs. With this we can create a custom property in a blueprint to be used for naming the VM.
In the right properties pane, remove the input variables and select On prem as FaaS Provider.
Save your Action.
Now we need to create a new blueprint which uses a Custom Property called newName. This property will be used in the Action to rename your VM. I’ll configure it as an input during request.
Go to Blueprints and create a new blueprint.
Save and close your blueprint.
Go back to Extensibility. Click Subscriptions. Click New Subscription.
Enter a Name and select Compute Allocation as Event Topic.
Toggle Filter events in topic and enter a condition. In my case I want the action to be related to the blueprint I just created. Here fore I need the blueprint ID. This ID can easily be found when going to the Blueprints tab and hover on the blueprint or selecting the blueprint. The hyperlink with the ID is than shown.
Add the following condition:
event.data.blueprintId == ‘your-blueprint-id’
Add your Rename VM action as Runnable item.
Toggle Block execution of events in topic.
Toggle the Subscription scope from Any project to your project. In my case the VMguru project.
Before going further, make sure that your Project isn’t configured with a Custom Naming template. Now request your blueprint.
Enter a custom VM name.
Go back to the Extensibility tab. Under Activity click Action Runs. Here you can see your actions being run after being triggered by an event broker subscription.
Click on the action run for more details. Select the Log tab.
Use Cloud-init to set the host name
In the previous paragraph we used an action to set the name of the VM. To make sure that the hostname in the Operation System equals this VM name, you can use Cloud-init to configure this. This off course requires a template with Cloud-init enabled!
Add the following Cloud-config to your blueprint:
Now, when you deploy a VM with custom name, this name will also be used as hostname in the Operating System.
That’s it. vRA 8 makes it very easy to create custom names for your VMs using Infrastructure as Code, Custom Naming per Project or using ABX with Event Broker subscriptions.
Other articles in the series vRealize Automation:
- Infoblox & vRealize Automation, Setup IPAM endpoint
- Infoblox & vRealize Automation, Install Infoblox IPAM plugin
- 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
- Missing endpoints after upgrading to vRealize Automation 7.3
- How to run Containers as a Service – Part 1
- How to run Containers as a Service – Part 2
- Infoblox & vRealize Automation, IP Address Management (IPAM) made easy
- How to run Containers as a Service – Secure Docker communications
- Create a new database user using vRealize Automation XaaS
- Infoblox & vRealize Automation, Infoblox NIOS setup
- Infoblox & vRealize Automation, vRA setup
- vRealize Automation failed requests monitoring
- vRealize Automation 7.2 released
- How to specify a deployment target when using vRealize Automation
- vRealize Suite just became a lot easier with Lifecycle Manager
- LAMP Stacks made easy with VMware and Puppet
- How to: Deploy vRealize Automation 8
- Create Custom Names with vRealize Automation 8
- Infoblox & vRealize Automation, vRA setup by Dimitri De Swart
- project-custom-properties by Dimitri De Swart
- What's new in vRealize Automation 7.5 by Erik Scholten
- Using input parameters to create dynamic blueprint… by Anne Jan Elsinga
- Designing your first Cloud Assembly blueprint for vSphere by Dimitri De Swart