Cloud Automation vCloud Automation Center vRealize vRealize Automation vRealize Suite

How to call vCAC (vRA) from command line to request VM’s and run scripts in the guest

So you want to make your developers happy but you are a vSphere admin and you already have enough on your plate? I am going to make it super easy for you to give your developers what they want (a command line to script their infrastructure request) and what you want, (an easy to use and administer UI). So let’s get started. A couple of things you will need in place:

  • vCAC 6.0 or 6.1 installed and configured
  • Linux Guest agent template see my guide How to create a vCAC 6 Linux Guest Agent Template
  • vRealize Cloud client 3.0, download from here.
  • An NFS server with a script directory available for your developers to mount to their Linux VM’s
  • A quite place to work for a few hours where you will not be interrupted.

Ok, so let’s get going!

Power on your Linux guest agent template and login as root or sudo to root and create directory on the root file system named repo. This is where you will mount your NFS share to.


Next, create a file named using the vi editor with the following content and save it.

mount -t nfs $1:$2 /repo &>/repomount.log

Make the executable by typing the following then pressing enter

chmod 777

Now shutdown your template. If you are using Linked clones you will also need to take a new snapshot and then run an inventory scan in vCAC and update the blueprint to point to the new snapshot

Now let’s create the build profile for this blueprint to use. Login to vCAC and navigate to the Infrastructure tab, then Blueprints, then Build Profiles and click to create a new build profile.


Now create the following build profile

VirtualMachine.Admin.UseGuestAgent true
VirtualMachine.Customize.WaitComplete true
VirtualMachine.Software0.ScriptPath / {repo.server} {repo.path}
VMware.VirtualCenter.OperatingSystem rhel6_64Guest

Now navigate to your Linux guest agent blueprint and attach this build profile to it and save it.



What this integration will actually do: It will call the script to mount the NFS share on the server you specify and to the directory you speicfy at request time. It will mount that NFS share to the /repo directory in the guest. Next it will execute the script you specify that is in the NFS share. The script will always need to run relevant to /repo.

Almost there, now we will need to create a test script on our repo server. I have setup a Linux server and I exported a directory named scripts as a read only NFS share. In that directory create a file named with the following and save it.


echo "hello world" > /helloworld.log

Now make the file executable by typing chmod 777 and press enter


Before we use the command line let’s do a smoke test from the UI, open the catalog and fire off a new request. Your request form should look like this.


Let’s fill in the details to test this integration. Fill int he fields below with your NFS information and click submit.


If all worked as expected, login to your newly requested VM and check the root for the helloworld.log file.


Ok enough using the GUI, we know developers don’t have time for that! Launch cloud client and accept the EULA. I am using the Windows version but it is written in Java so it works on Linux too, type cloudclient.bat You should see the following screen.


Now we need to login to our vCAC instance, type the following to connect


vra login userpass --user --password MyPassword --server --tenant mytenant

Type the following to verify connectivity

vra catalog list

Now let’s request that VM, mount a repo and run scripts in the guest. Type the following and press enter.

vra catalog request submit --groupid "Rainpole Developers" --id CentOS6 --reason Because --properties repo.path=/scripts,repo.server=,,VirtualMachine.Software1.ScriptPath=/repo/,provider-VirtualMachine.CPU.Count=1,provider-VirtualMachine.Memory.Size=512

In the vCAC portal you should see a new request in progress. But let’s take a look from the command line. Type vra provisioned item list and if your machine is ready you should see the following.


Open an SSH session to your new machine and check for the helloworld.log file


Let’s just recap what we did and think about how powerful this is for your developers.

  1. We created a Linux blueprint with the vCAC guest agent installed and configured
  2. We added a repomount script to the Linux template that will mount a repo directory where a developer could call whatever scripts they want in the guest
  3. We created a custom build profile that will take user input at request time so requester can specify the repomount server they want, the NFS share and the script they want to run in the guest
  4. We requested a new VM, specified the repo server and NFS share and the script we want to execute in guest from a command line
  5. Verified the script ran in the guest

So where do we go from here! Now your developers are enabled to write scripts that can do a number of things like install software, configure the server, pull artifacts from a repository, install configuration management solutions like Chef, Puppet, Salt or Even docker. All of this completely scripted and automated. The future is now!!


2 comments have been added so far

  1. Thanks for this post, i installed cloud client its gets installed properly also able to login.
    but vra blueprint list command not working.
    CloudClient>vra blueprint list
    Command ‘vra blueprint list’ not found (for assistance press TAB)
    i tried other command like vra request list that command is giving same output. any idea why it is not giving expected output.
    please help.

Leave a Reply

Your email address will not be published.