Tocano
Enthusiast
Enthusiast

Can you add a custom Powershell module to the vRO8 PSCore instance?

Jump to solution

Looking at Get-Module -ListAvailable, it lists the modules as being in /root/.local/share/powershell/Modules/. I'm assuming that since this directory doesn't exist on the appliance, that this path reflects something in a container.

So is it possible to drop a Module folder somewhere on the appliance to get picked up by the vRO Powershell environment?

Thanks

1 Solution

Accepted Solutions
maverix7
VMware Employee
VMware Employee

Yes, it is possible. You need to bundle your script with all dependencies in a zip and upload the zip to the action. It is shown in this use case:
Create a PowerShell Script That Calls the vRealize Automation Project API


Or if you want to focus only on the 3rd party modules, check here:
vro-polyglot-scripts/powershell/3rd-party at master · tgeorgiev/vro-polyglot-scripts · GitHub

View solution in original post

8 Replies
daphnissov
Immortal
Immortal

Not to my knowledge, because that would involve altering the Kubernetes manifest which runs the container image which is unsupported and won't be preserved.

0 Kudos
maverix7
VMware Employee
VMware Employee

Yes, it is possible. You need to bundle your script with all dependencies in a zip and upload the zip to the action. It is shown in this use case:
Create a PowerShell Script That Calls the vRealize Automation Project API


Or if you want to focus only on the 3rd party modules, check here:
vro-polyglot-scripts/powershell/3rd-party at master · tgeorgiev/vro-polyglot-scripts · GitHub

View solution in original post

Tocano
Enthusiast
Enthusiast

So I've been working on this and am a little confused. So I create a folder, add a handler.ps1 script, add whatever module(s) I want to a .\Modules subfolder, and make sure it gets imported by the handler function. Then I zip the whole thing up and upload to an action.

Does that mean that I need to run this action as effectively an Import-Module step whenever I want to use something from the module?

0 Kudos
maverix7
VMware Employee
VMware Employee
So I create a folder, add a handler.ps1 script, add whatever module(s) I want to a .\Modules subfolder, and make sure it gets imported by the handler function. Then I zip the whole thing up and upload to an action.

That is correct

Does that mean that I need to run this action as effectively an Import-Module step whenever I want to use something from the module?

Not needed, those modules are imported by default when the script is ran. You will need to explicitly "Import-Module" in rare occasions where you want to use an older module than the ones in the system.

0 Kudos
Tocano
Enthusiast
Enthusiast

I see. Thank you.

So then it would seem that anytime the code for the PS module(s) gets updated, I would have to repackage and re-import a new version of the action. Is that correct?

If so, that seems ... cumbersome for environments like ours where our set of modules get updated every week or so. Is there a better way I'm not considering? Like maybe Bind Mounts or something? Which would allow us to easily update a folder on the host that gets utilized within the container.

I'm really trying to figure out how to avoid thinking that the architecture move to containers, which should allow the flexibility to create customized environments with self-contained instances of the code, configurations, and other libraries/modules that a system needs, would actually be MORE difficult than a static appliance.

Sorry if it sounds like I'm being critical of you. Smiley Happy  Certainly not my intent.

Again, I appreciate the help.

maverix7
VMware Employee
VMware Employee

Hi Tocano,

I now understand more about your use case. The architecture change (or more addition) to move to containers for vRO PS scripts was made to get script isolation and environment flexibility. And I think vRO did the job well on the execution aspects of it. About your concern, I think we can think of it as script packaging/distribution problem, which as you point it out seems cumbersome for what you want to achieve. I can bring your comments to the vRO team. At the moment I can only suggest to introduce some additional (not OOB) process that will bundle the zip and use vRO's API to update the actions, which might as well be another PS action 🙂

Thanks

0 Kudos
ISMI
Contributor
Contributor

Hi, 

 

We have exactly the same case here. I need to add some additional modules but we don't want to manually push / update the zip to vRO, we are exactly  working for automate everything here :). 

Do you have some api manipulation example for update a vRO script action?

Is there a way to execute script inside a custom k8s pod ?

 

thanks a lot.

maverix7
VMware Employee
VMware Employee

ISMI I will note that as well Smiley Happy

you can use the following API to update the bundle of an action:

POST https://{VRO_SERVER}/vco/api/actions/{ACTION_ID}/bundle

Content-Type: multipart/form-data;

Form data:

  bundle: {binary}

0 Kudos