Cloud Templates in vRealize Automation 8.X – Formerly Know as Blueprints

vRA Cloud Templates, formerly known as Blueprints form the foundation that leads to Infrastructure as Code or IaC, one of the concepts that every IT pro hears today. The logic behind IaC is that the same resource is provisioned every time the code is executed and it’s one of the pillars of DevOps lifecycle. In vRealize Automation, with the help of YAML, you can code resource provisioning according to your environment requirements.

before we continue, let’s see what are the basics of YMAL. YAML which is a serialization language with key: value pairs offering a human-readable tool for the configuration of systems. Let’s get in more details.

Comments in YAML

As almost all programming languages, # is used when commenting in the code, just put a # in the beginning of a sentence and the whole line is considered as comment.

if the sharp sign is placed within single or double quotation marks, then it’s not considered as comment.

Key-Value Pairs

YAML stores data in the format of keys and values or <KEY: VALUE>.

YAML and Spaces

Spaces are used to indent a YAML code. Codes that are at the same level must have the same indentation. Spaces will help to form a hierarchy. In the following example, “SelectFlavor” has the properties of “type”, “title”, “enum” and it is under “inputs” itself. That means there is no relationship between “title” and “inputs”.

Lists in YAML

When defining variables or inputs, you sort of need lists. Consider the following when defining lists in YAML:

  • Start with a name followed by semicolon. (Ex: “Size:”)
  • on the next line, after indenting (space) place a hyphen (-) before the first item of the list. Do the same thing for the rest of items. (indentation must be equal to other items in the list – the same number of spaces)
  • No key has to be associated with the items in the list.

You can see in previous example above, there is a list that has items Small, Medium, Large under inputs.

Variables in YAML

Variables in YAML like what we have in Powershell starts with $. Variables are used when referencing other components. They also can be used with user inputs.

The very first part of the variable name references the actual location in YAML code that the variable has been retrieved from.

in the example above, you can see that one variable has been defined. You should see that the variable is somewhere else defined and has its own properties.

User Inputs in YAML

Whenever you require the user to provide some inputs, for example the size of VM disk, or the image of the VM, you need to use “Inputs”. Input is defined as a variable and then the variable will be used where required. The format will be like this:

‘${input.<VariableName>}’

Now that you are familiarized with some of the concepts of YAML, lets get into the vRA console and see how we can get it configured.

Cloud Assembly – Design

From the Design tab in Cloud Assembly, click new form and select Blank canvas.

In the New Cloud Template wizard, give a name and select the project that you want to associate it with it. You can also select whether to be able to share it with other projects or not. click Create.

Now you will be presented a new page that three different panes: Components, Design Canvas, YAML Code as depicted below.

The design canvas gives you the ability to drag and drop from components pane, and the respective YAML code will be populated. As you can see in the components pane, there is a possibility of provisioning from vSphere or other supported platforms. let’s see it in practice.

I define some inputs first:

Now, from the left pane, drag and drop the following components to the design canvas.

  • Cloud vSphere VM
  • Cloud vSphere Disk
  • Cloud vSphere Network

using the object connector, connect Disk and Network components to the VM. once done you can see the YAML code window will be updated.

Now it’s the time to specify the properties of VM that the user can define. As shown before, we created some input variables above, we can use these inputs in the properties of VM, with following format:

for example, if you want to define cpuCount property:

Doing the same thing with all the inputs, you will end up with the code below.

Now you can deploy what has been designed to see the result, to do so, click on Deploy button. Give your deployment a name and hit next.

In the next page, you can see that all the inputs that were defined are presented and you can customize the deployment with your desired values.

click deploy. Now from the Deployments tab you can see the status of the deployment.

Once this is done, you can see the “create successful” in green box. That shows that your configuration worked fine.

I hope this’s been informative for you. keep an eye for the next posts.

Leave a Reply

Your email address will not be published.