Software - CoolRun
This package enables Aia Orchestrator to run scripts of various types inside a VM using VMware tools. This makes it possible to run scripts in VMs without network connectivity or without requiring to punch holes into the firewall.
Aria Orchestrator is licenced and owned by VMware.
UPDATED VERSION 6.6 (10/03/24)
Features
Easy-to-use script running engine
Replace {tags} in the script template with values from vRO
Can use Windows, Linux, (virtual) ESXi, MAC and Photon OS
Runs Linux Bash, Linux PHP, Linux Python, Linux Perl, Windows DOS, Windows PowerShell, Windows Diskpart
Can be easily adapted to run other OSs or Script types
Stores Configuration centrally and differentiates between Linux and Windows login credentials
CoolRun simplifies script execution within a virtual machine (VM) by streamlining processes like copy, run, and check. Utilizing {tags} within scripts allows dynamic substitution with values from vRO. The workflow includes preconfigured script execution settings for Linux Bash, Linux PHP, Linux Python, Linux Perl, Windows DOS, Windows PowerShell, and Windows Diskpart.
For instance, users can design a workflow to add a new disk to a Windows VM, followed by executing Windows Diskpart for partition creation, formatting, and assigning a label.
CoolRun is designed for versatility, making it easily adaptable to other scripting languages and operating systems.
Installation and configuration
Please see the infrastructure requirements at the bottom of this page.
Import the vRO package into your vRO appliance
run the workflow configure CoolRun
run a test scrip on either Windows or Linux VM
The configuration program will ask for all the required information to run a script inside a VM. The configuration is saved in a configuration file and a DOS or BASH Test can be run.
The example will ask for a VM your name as well as a working directory. The advanced feature lets you define different credentials.
Basic Usage
Create a script (see bash/dos example beneath)
echo "Hello {user.name}, have fun with coolRun" > {user.dir}text.txt
Save the script as a Text file and upload it into vRO as a resource element
Create a new workflow
Add the coolRun SubSystem workflow
Create an attribute of type ResoruceElement and link it to the script you uploaded.
Use a Scriptable task with an OUT-attribute of type Properties, called payload.
Define the following workflow input variable:
Name |
Type |
Usage |
vm |
VC:VirtualMachine |
VM on which to execute |
name |
string |
your name |
workingDirectory |
string |
directory where the output should be stored |
In the scriptable task define the payload (see example beneath, all bold names are variables)
var payload= new Properties();
payload.put("vm",vm);
payload.put("wrapper","dos");
payload.put("script",exampleScript);
payload.put("workingDirectory",workingDirectory);
var scriptVariables= new Properties();
scriptVariables.put("user.name",name);
scriptVariables.put("user.dir",workingDirectory);
payload.put("scriptVariables",scriptVariables);
Pass the Payload to the coolRun Subsystem workflow
Run the workflow
Modifications and extensions
CoolRun is built so that it can be easily extended to run with other OS types and script types. In order to add an OS or script type, you just need to configure the switch element before either the OS Type or the Script Type.
For OS the following output variables are needed:
Name |
Type |
Usage |
workingDirectory |
string |
where should the program run (e.g. c:\ or /tmp/) |
vmUsername |
string |
final username to be used |
vmPassword |
string |
final password to be used |
vmEnvironment |
array of strings |
(can be empty) final Environment variables to be used |
For scipts the folowing output varibales are needed:
Name |
Type |
Usage |
arguments |
string |
arguments of the program to be executed (e.g. /tmp/script.txt) |
guestFilePath |
string |
where should the program be put on the VM (e.g. /tmp/script.txt) |
programPath |
string |
path of the program to be executes (e.g. /bin/bash) |
If you want to overwrite existing settings with user input, use the following little function
function exists(prop,key,alt){
temp=prop.get(key);
if (temp==null){
return alt;
} else {
return temp;
}
}
vmUsername=exists(payload,"vmUsername",WinvmUsername);
Under the covers
CoolRun is based on the VMware vRO library functions of the guestOperationsManager, at some stage known as VIX. What the guestOperationsManager does is use VMware tools in the VM’s OS to interact with the ESXi the VM is residing on.
It is actually only a wrapper that makes it easier to execute commands using the Guest Operations, it cleans up the code, escapes characters such as \, makes sure that directories exist and so on.
The prerequisites are the following.
(as far as I have found them…cause I couldn’t find any clean documentation):
VMware tools must be installed and running on the Target VM
Local (on the VM’s OS) user credentials should have Admin/root rights
vRO must be able to access the vCenter on TCP 443
VRO must be able to access the underlying ESXi host on port TCP 443
In Windows, it can get tricky with UAC and other such things. I normally just use “.\administrator”. After finishing up, I reset the local Administrator password.
Variables
The input to CoolMail is a property that is defined as:
Property Key Name |
Type |
Required |
||||||
vm |
VC:VirtualMachine |
yes |
||||||
script |
Resource Element |
yes |
||||||
wrapper |
String |
yes |
||||||
vmUsername |
String |
No |
||||||
vmPassword |
Secure String |
No |
||||||
timeout |
number (default: 0) |
No |
||||||
waitTime |
number (default: 5 sec) |
No |
||||||
delGuestFile |
Boolean (default: false) |
No |
||||||
delLocalFile | Boolean (deafult: true) | No | ||||||
environment |
array of string |
No |
||||||
workingDirectory |
string |
No |
||||||
OSName | string | No | ||||||
debugFlag | Boolean (default: true) | N0 | ||||||
interactive | Boolean (default: false) | No | ||||||
showScript | Boolean (default:true) | No | ||||||
showPassword | Boolean (default: false) | No | ||||||
failOnError | Boolean (default: false) | No | ||||||
fireAndForget | Boolean (default: false) | No | ||||||
scriptVariables |
|
No |
All variables that are not required can be used optionally to overwrite the existing values defined in the configuration element.
Optional function |
Usage |
vmUsername |
Overwrites the configured Linux or Windows username |
vmPassword |
Overwrites the configured Linux or Windows password |
timeout |
maximal time in seconds CoolRun is waiting until it kills the script process. If set to 0 timeout is disabled. Default: 0. |
waitTime |
time in seconds to wait before each check if the script has finished. Default: 5 |
delGuestFile |
should the script file in the guest VM be deleted after it has been executed? |
delLocalFile | Should the scipt filr in the vRO appliance be deleted after it has been executed? |
environment |
Overwrites the configured Linux or Windows environment variables |
workingDirectory |
in what directory should the script be executed. |
OSName | Name of the OS. If not present vm.guestOS will be used. |
debugFlag | Switching on or off debugging via payload |
interactive | use interactive session for VM connection. e.g. If executing "net use" commands, only interactive commands are working correctly |
showPassword | Shows the vmPassword in the log file |
showScript | Shows the script taht is send to the VM in the log file. As this may contains cleartext passwords this setting disables showing the script. |
failOnError | CoolRun will exit with an error if the ExitCode of the script exectution was not 0 (zero) |
fireAndForget | Do not wait for exit code of the script, just execute the script and be done. Will ignore failOnError, Dos not work with interactive |
Wrappers
The wrappers are the scipt type that is executed on the VM OS
Optional function |
Usage |
dos |
Run a script using Windows CMD |
php | Run a script using linux php |
bash | Run a script using linus Bash |
perl | Run a scipt using Linux perl |
python | Run a script using Linux python |
powershell | Run a script using Windows PowerShell 32bit c:\windows\syswow64\WindowsPowerShell\v1.0\powershell.exe |
diskpart | Run a script using the Windows diskpart program |
cmdPowershell | Run a script using Windows PowerShell started via CMD call c:\windows\system32\cmd.exe /c powershell.exe -ExecutionPolicy RemoteSigned |
powershell64 | Run PowerShell 64bit C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe |
regImport | Import Windows registy files that have been exported with reg export reg import |
Example packages
The examples can be found in the Langenhan.solutions / coolRun / Example Workflow folder and in ResourceFolder Langenhan.solution / scripts. They contain the following examples:
ChangeDiskLabel
Using the diskpart wrapper, it changes the letter of a disk.diskAdd
Using the diskpart wrapper, it adds a disk to the OS, set gpt partition it and format itdiskExtend
Using the diskpart wrapper, it extends an existing disk partitiondnsAddCommand
Using the DOS wrapper, it adds a DNS record to an AD DNS serverdnsDelCommand
Using the DOS wrapper, it removes a DNS record to an AD DNS serverpsDiskAdd-lun
Using the PowerShell wrapper, it adds a disk to the OS, partitions it and formats it.psDiskExtend-lun
Using the PowerShell wrapper, it expense an existing disk in the OS
Change Log
Version (of "CoolRun Subsystem") |
Date | Change |
6.6 | 10.03.24 |
The following was fixed:
|
6.5 | 02.07.23 | Minor changes, New Business Name |
5.0 | 14.09.20 | vRO 8.x ONLY
|
4.4.0 | 16.10.19 |
|
4.3.0 | 20.09.19 |
|
4.2.0 | 16.08.19 |
|
4.0.6 | 20.11.18 |
|
4.0.5 | 13.11.18 | Build problems....
Special thanks to Kjeld Thorlund for finding the bugs. |
4.0.3 | 12.11.18 | Pre-requisite Checker Cleaned up Schema and added comments added debug Flag option added more logging added clean-up for Carriage return for Linux Scripts added check for Working Directory and creating it if necessary extra Workflow for clean-up of local vRO File Clean-up example workflows added exit code as output |
0.3 | 23.07.18 | added showPassword (VMpassword is not shown in debugglog) added interactive (to trigger interactive session fixed testing and debugging issues |
0.2 | 04.07.18 | Support for MacOS, Added optional value OSName, Working Directory is not a required field anymore.fixed configuration workflow and file. |
0.1.3 | 22.12.17 | fixed Centos detection, added cmdPowershell extention |
0.1.1 | 21.09.17 | Initial Web published version |