Do you use a lot of Polyglot scripts in vRO? Are you tired of creating bundles every time you work on a Python, Node.js or PowerShell script which uses modules and libraries which are not provided out-of-the-box by vRealize Orchestrator? Probably vRO guys at VMware heard your prayers this time.
vRO 8.8 onwards, you can now add modules and libraries directly as a dependency in your vRO actions and scriptable tasks. How cool is that!
As we know, in earlier versions, you could only add dependencies by adding them as a ZIP package which is not only a tiring additional steps, but also, editing and understanding those scripts becomes a real nightmare. But not any more.
In this post, we will see a detailed procedure on how to setup an script environment in your vRO (>8.8). I am going with Node.js but almost similar process can be followed for other languages as well. We will use an advanced date & time library called MomentJS available at https://momentjs.com/ but you can use any other module or library of your choice for that matter.
Note Similarly to other vRealize Orchestrator objects such as workflows and actions, environments can be exported to other vRealize Orchestrator deployments as part of a package, which means they are also a part of version control.
- vRealize Orchestrator 8.8 or greater
- Log in to the vRealize Orchestrator Client.
- Navigate to Assets > Environments, and click New Environment.
- Under the General tab, enter a name for your environment.
- (Optional) Enter a description, version number, tags, and group permissions for the action.
- Under the Definition tab, Click on Add button under Dependencies.
You can also change the Memory Limit to 128, 512, 1024 etc. depending on the number and size of packages that you will be using. In my personal experience, using PowerShell modules will require more than default.
- Provide the package name and version that you want to install. For Node.js, passing
latestwill get you the most recent package.
Tip The package name is same as what you would use with package managers like npm while installing that package.
- Once you click Create button, you should see Environment successfully created.
- Under the Download Logs tab, check if the libraries are already installed.
Here, I have installed two modules,
moment-timezone as you can see from the logs.
- In the Environment variables, you can provide a variable that you want to use as a part of this environment.
- Create an action or a workflow with scriptable item, Select Runtime Environment as the one that you have created. I have selected moment.
- Play with your script. Don’t forget to call the modules and environment variables.
Calling modules & variables
const myModule = require('moment'); const envVar = process.env.VAR_NAME;
import myModule os.environ.get('VAR_NAME')
Import-Module myModule $env:VAR_NAME