IaC for vRealize: Updating Archetypes and Adding Boilerplate For Your vRO Actions

Welcome to the 5th post in the series. This is going to be a relatively small post where we will take a look at archetypes and how to update these and also discuss a standard layout for creating vRO Actions. At this stage, the focus is on ensuring that we have everything required when creating new projects, instead of having to add new files to the project or modify existing ones.


By now you have come across the term ‘archetype‘ when working with Maven. If you’re not a Java developer or ever worked with Maven before, then you likely have no idea what this means in the context of creating projects.

Here is a dictionary definition for archetype:

So if we look at the first definition, we can think of a Maven archetype as a model for our projects. In essence, think of an archetype as a ‘template’ for Maven projects.

Notice what happens when we create a project for the first time, we would execute a command similar to this:

mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=com.vmware.pscoe.o11n.archetypes -DarchetypeArtifactId=package-actions-archetype -DarchetypeVersion=1.5.11 -DgroupId=com.simplygeek.library -DartifactId=nsx

We specify ‘archetype:generate‘, which tells Maven that the project should be generated from an existing archetype. We also specify ‘archetypeGroupId‘, ‘archetypeArtifactId‘, and ‘archetypeVersion‘, which tells Maven how to find the archetype.

Once we have executed the above command, Maven will download several artefacts that it requires for the project. Once this task completes, you will have a directory structure that looks something like the following (depending on what type of project you are creating):

The ‘src‘ directory also includes a ‘main‘ and ‘test‘ subdirectory that includes a sample Action and unit test.

This directory structure and the files have been predefined inside of an archetype. When a new project is created, Maven downloads this archetype and unpacks the contents to form the project directory. This means that every project that we create will look the same.

But what if we want to change this, or perhaps add additional files or update existing ones? Well, it’s quite easy, we just have to locate the artefact for the archetype and update it.

Update Existing Archetype

If you think back to the very first post, we downloaded the vRealize Build Tools package from the VMware flings website. From within this package, there was an ‘iac-maven-repository.zip‘ file, which we copied to a CI server (I used the Artifactory server in my first post). This file includes all the archetypes that are used for our projects.

Depending on which project type you create, the following archetypes are available:

  • iac-maven-repository/com/vmware/pscoe/o11n/archetypes/package-actions-archetype
  • iac-maven-repository/com/vmware/pscoe/o11n/archetypes/package-mixed-archetype
  • iac-maven-repository/com/vmware/pscoe/o11n/archetypes/package-vrealize-archetype
  • iac-maven-repository/com/vmware/pscoe/o11n/archetypes/package-xml-archetype
  • iac-maven-repository/com/vmware/pscoe/vra/archetypes/package-vra-archetype

Inside each of these directories, there is a ‘<version>/<archetype>-<version>.jar‘ file and an associated pom file. For a JS based project, you will see:

The jar file is just a zip file and can be opened with any zip software. When you open this file (I’m using 7Zip on WIndows) then you will see two folders, ‘META-INF‘ and ‘archetype-resources‘.

If you navigate into ‘archetype-resources‘, you will see the same folder structure that you get when creating a new project. Read more “IaC for vRealize: Updating Archetypes and Adding Boilerplate For Your vRO Actions”

IaC for vRealize: Manage Existing vRO Code With vRealize Build Tools & Set up Git Repositories

In my previous post on Deploying vRealize Build Tools To Allow Infrastructure As Code for vRA and vRO, I covered how to set up the CI infrastructure and your developer workstation, in preparation for managing your vRO code as projects with Visual Studio Code and Maven. In this post, I will explain how you can work with your existing code base and manage it using the build tools. A major part of this will be creating and managing new projects that will map to our existing code in vRO.

Once projects have been created, I will detail how Git repositories can be used to store and manage your vRO code, and then we can map your project dependencies and allow development teams to work collaboratively, without risk of overwriting the work of others (a major problem when developing using the vRO client). Git is going to bring some very useful processes and methodologies to the table such as branching, tagging and merge conflict resolution.

I also want to point out that I am currently only focusing on Actions, as I believe this is where all your code should exist. I will have followup posts that will cover strategies for managing Workflows and other items.

Setting Up GitLab

One thing that I didn’t cover in my previous post, was setting up Git. I purposely reserved this topic for this post, as it was more relevant. To start, you will need to have a GitLab server deployed that can be used to create the repositories for storing your vRO projects. You can use GitHub if you so wish, it doesn’t matter too much, but using GitLab doesn’t require that your environments have access to the Internet. GitLab also allows you to create groups to organise multiple repositories, which is going to be useful.

If you need to install GitLab, then there is a good guide on VULTR, that details how to install GitLab and enable HTTPS.

Create User

You should be using your user account when working with Git and not the default root account. So log into the admin area and create a new local account for your personal use. Alternatively, you can also configure GitLab to allow users from Active Directory to log in, you can use the guide provided by Git here.

Create a Personal Access Token

Once you have a Git user account set up, you will need to create a Personal Access Token. An Access Token can be used instead of a password when authenticating with Git over HTTPS. This will provide safer storage of user credentials in the Git configuration files.

Click on the profile icon on the top right of the page and select Settings:

On the Settings page select Access Tokens.

On the ‘Add a personal access token‘ page, give the access token a name and the ‘write_repository‘ permissions. Set an expiry date if you wish, or leave blank to never expire.

Once you click ‘Create personal access token‘, the token will be displayed. You will need to copy and save this token somewhere safe as you will not be able to view it again. If you lose this token, you will have to create a new one to replace it.

Create a Group

A Group allows multiple projects/repositories to be created under a single namespace. This is useful when a project spans many repositories and you need to keep these together so that they are easy to locate and manage. Our vRO projects will be using multiple repositories, therefore we’ll great a Group for these. A Group also simplifies granting access to projects, as collaborators can be granted access to the group and inherently, the projects it contains.

To create a new group, select ‘Groups‘ from the main menu at the top and then select ‘Your groups‘.

Click the ‘New group‘ button and give your group a name and settings that you require (I simply called my group ‘vRO’).

We will create all vRO projects under this new group.

Install Git Client

You will also need to install the Git client for your workstation. You can download the client for your OS here. Read more “IaC for vRealize: Manage Existing vRO Code With vRealize Build Tools & Set up Git Repositories”