VMware Aria Automation Orchestrator

 View Only
  • 1.  Connecting to a deployment using SSHSession fails with Unknown Host

    Posted Jun 05, 2025 01:33 AM

    Hi All,

    Fairly new to vRO but get the idea and starting with a simple script - or so I thought. When a VM deploys, I have a vRA Subsription that calls my Workflow under the Post Compute Event Topic.

    The workflow will connect to the VM via a SSHSession and then run some commands. It fails at the point where the "connectWith Password" is read. If I comment out that line, the rest of the script runs fine. I'm not sure if this is a coding issue with the way I'm calling it or somthing to do with DHCP assigning the IP to the VM (hence I added a sleep to give it time to settle). I have refreshed DNS to watch for the A record being created, and set the sleep to a value way beyond whats required.

    The "var_securepassword" variable is defined in the Variables of the Workflow - as a SecureString and added as an Input to the Scripting item.

    Any ideas, much appreciated

    MY SCRIPT:

    //sleep for a bit to allow DHCP to register
    System.sleep(60000);

    var session = null;

    //create var to hold commands
    var cmd = "touch /tmp/stuvro";

    //cretae a variable to hold resource Names
    var resourceName = new Properties();
    var addresses = new Properties();

    resourceName = inputProperties.get("resourceNames");
    resourceHost = resourceName[0];
    addresses = inputProperties.get("addresses");
    var address = addresses[0];
    System.log(resourceHost);
    System.log(address);

    //create a variable to hold the customProperties from the Project
    var customProperties = new Properties();

    //assign customProperties to variables for use in later code
    customProperties = inputProperties.get("customProperties");
    System.log("gevSudoGroup: "+ customProperties.get("gevsudogroup"));
    System.log("gevUserGroup: "+ customProperties.get("gevusergroup"));
    System.log("gevSubsKey: "+ customProperties.get("gevsubsmgrkey"));

    sudoGroup = customProperties.get("gevsudogroup");
    userGroup = customProperties.get("gevusergroup");
    subsActKey = customProperties.get("gevsubsmgrkey");

    session = new SSHSession(address, sshuser, 22);
    System.log("AddressUsed: "+ address);
    System.log("UserUsed: "+ sshuser)
    System.log("PasswordUsed: "+ var_securepassword)
    session.connectWithPassword(var_securepassword);
    //session.executeCommand(cmd, true);

    LOG OUTPUT form failed Run:

    2025-06-04 14:32:44.462 +01:00 info  ST-020
    2025-06-04 14:32:44.463 +01:00 info  10.10.10.10
    2025-06-04 14:32:44.464 +01:00 info gevSudoGroup: SPT
    2025-06-04 14:32:44.465 +01:00 info gevUserGroup: USR
    2025-06-04 14:32:44.466 +01:00 info  gevSubsKey: ITOPS
    2025-06-04 14:32:44.467 +01:00 info  AddressUsed: 10.10.10.10
    2025-06-04 14:32:44.468 +01:00 info  UserUsed: vraadmin
    2025-06-04 14:32:44.469 +01:00 info  PasswordUsed: mysecurepassword
    2025-06-04 14:32:44.521 +01:00 error  Error in (Workflow:GEV_vRA8 VM Config Workflow / RHEL Setup Script (item1)#36) java.net.UnknownHostException: org.mozilla.javascript.NativeArray@3b0ae7e1
    2025-06-04 14:32:44.531 +01:00 error Workflow execution stack: 
    ***
    item: 'GEV_vRA8 VM Config Workflow/item1', state: 'failed', business state: ' ', exception: 'java.net.UnknownHostException: org.mozilla.javascript.NativeArray@3b0ae7e1 (Workflow:GEV_vRA8 VM Config Workflow / RHEL Setup Script (item1)#36)' 
    workflow:  'GEV_vRA8 VM Config Workflow' (2799f9f4-96cf-45fa-a787-b6e1abcf7d59) 
    | 'attribute': name=var_securepassword type=SecureString value=__NULL__
    | 'attribute': name=sshuser type=string value=vraadmin
    | 'input': name=inputProperties type=Properties value={9:40:addresses=Array#[29:Array#[18:string#10.6.60.217]] 
    11:30:componentId=string#Cloud_vSphere_Machine_1 
    10:43:endpointId=string#dc9604ba-6213-4776-947b-19fc502bf583
    11:54:externalIds=Array#[43:string#50204be4-b171-bd1a-505e-e43aca6357df]
    11:43:blueprintId=string#1d751942-4193-40ce-be3a-0ffdb68389ee
    4:13:tags=Properties#{}
    13:24:resourceNames=Array#[13:string#ST-020] 
    16:910:customProperties=Properties#{18:12:neglectPowerOffVms=string#false
    17:26:customizationSpec=string#LIV-RHEL9-DHCP-Spec
    5:19:image=string#LIV RHEL9.4a
    25:11:zone_overlapping_migrated=string#true 
    12:14:endpointType=string#vsphere
    12:22:gevusergroup=string#USR 
    7:43:project=string#2f36f905-5b2c-4753-8917-433779cbc0b9
    16:7:migrationMessage=string#
    13:17:datastoreName=string#livvx-vsan 
    14:27:cloneFromImage=string#odsp-liv-rhel94-min3
    9:8:coreCount=string#1 
    13:20:gevsubsmgrkey=string#ITOPS
    12:42:softwareName=string#Red Hat Enterprise Linux 9 (64-bit)
    12:22:gevsudogroup=string#SPT
    6:12:osType=string#LINUX 
    12:43:instanceUUID=string#50204be4-b171-bd1a-505e-e43aca6357df
    15:14:migrationStatus=string#STARTED 10:10:folderName=string#DEV 
    12:56:vmFolderPath=string#[livvx-vsan] c1494068-6854-38b4-d396-0c42a16c9a5c 
    10:12:isSimulate=string#false 6:43:vcUuid=string#8a8bc34d-efb6-407b-9392-59b6ed0dcb8f }
    15:28:componentTypeId=string#Cloud.vSphere.Machine
    9:43:requestId=string#b7deb748-93c2-4964-9ccc-f35933a12c99
    12:46:macAddresses=Array#[35:Array#[24:string#00:50:56:a0:f3:bc]]
    12:43:deploymentId=string#4ca88358-3729-4e16-bdcb-678e678e7486
    6:43:zoneId=string#587a9b9f-e815-40d2-80a1-62a5882893cb
    9:43:projectId=string#2f36f905-5b2c-4753-8917-433779cbc0b9
    9:65:subnetIds=Array#[54:Array#[43:string#c7053d52-ceb9-4398-8ecf-042f9163d526]]
    11:54:resourceIds=Array#[43:string#b56b7820-ca18-4b61-b462-ef7d4f17ca00]
    }
    | 'attribute': name=__metadata_userName type=string value=vraadm
    | 'attribute': name=__metadata_hdr_blocking type=string value=true
    | 'attribute': name=__metadata_contextOrgId type=string value=null
    | 'attribute': name=__metadata_correlationType type=string value=contextId
    | 'attribute': name=__metadata_hdr_tokenId type=string value=kSt4+niQ2uYRaGWmy7iQAkK8xTQ08YKPp8E0C1IQvY4=
    | 'attribute': name=__metadata_hdr_eventTraceEntryId type=string value=51bbed19-9ebb-4685-9b27-d2f0d0adc57e
    | 'attribute': name=__metadata_hdr_traceparent type=string value=00-68404a44738fa8eef215104b037bd3c3-72926700a6b33359-01 
    | 'attribute': name=__metadata_orgId type=string value=bdc64add-af7a-4ab9-a79e-9a12045c955f
    | 'attribute': name=__metadata_description type=string value=null
    | 'attribute': name=__metadata_targetType type=string value=ComputeProvisionTaskState 
    | 'attribute': name=__metadata_eventTopicId type=string value=compute.provision.post
    | 'attribute': name=__metadata_sourceIdentity type=string value=35f1519c-d4d0-48b4-b911-fcea7465ab7b
    | 'attribute': name=__metadata_targetId type=string value=ab0c796e-edc3-44cd-9681-2d0065389c84
    | 'attribute': name=__metadata_sourceType type=string value=provisioning
    | 'attribute': name=__metadata_eventType type=string value=EVENT 
    | 'attribute': name=__metadata_hdr_provisioning-callback-uri type=string value=/provisioning/config/extensibility-callbacks/5293d15c-c2ed-3f12-aac8-af552a4d4a49 
    | 'attribute': name=__metadata_id type=string value=5293d15c-c2ed-3f12-aac8-af552a4d4a49 
    | 'attribute': name=__metadata_hdr_encryption-context type=string value=4ca88358-3729-4e16-bdcb-678e678e7486 
    | 'attribute': name=__metadata_hdr_runnableId type=string value=2799f9f4-96cf-45fa-a787-b6e1abcf7d59 
    | 'attribute': name=__metadata_hdr_runnableType type=string value=extensibility.vro
    | 'attribute': name=__metadata_correlationId type=string value=4ca88358-3729-4e16-bdcb-678e678e7486--b7deb748-93c2-4964-9ccc-f35933a12c99
    | 'no outputs'
    *** End of execution stack.


  • 2.  RE: Connecting to a deployment using SSHSession fails with Unknown Host

    Posted Jun 05, 2025 02:31 AM

    Hi Stuart,

    There's a built-in workflow called "Run SSH command." Could you please manually deploy your Linux server and run that workflow against it? This will confirm that vRO can SSH into the server in general. 



    ------------------------------
    If you find the answer helpful, please click on the RECOMMEND button.

    Please visit my blog to get more information: https://clouddepth.com
    ------------------------------



  • 3.  RE: Connecting to a deployment using SSHSession fails with Unknown Host

    Posted Jun 05, 2025 04:04 AM

    Thanks, I saw the Built in one but struggled with how to pass it the inputProperties I need and the password etc, so I extracted from it the lines that make the SSH  connection. I'll have another play with it today.

    Do I have to create an additional workflow to extract the inputProperties etc in to variables, then create a master workflow that contains my workflow and the built in SSH one - then link the Input and Output Variables between them?  Or is there a more straight forward way to just use teh Built in SSH one?

     I'm also going to try Hard Coding another server in to my script to see if the code can SSH to anything at all




  • 4.  RE: Connecting to a deployment using SSHSession fails with Unknown Host

    Posted Jun 05, 2025 04:16 AM

    You don't need to pass anything. Just run it. It will execute a default "uptime" command on the remote server and return the output. If that works, it will confirm the vRO is able to "talk" with the remote server. Means there are no firewalls, etc. between them :)



    ------------------------------
    If you find the answer helpful, please click on the RECOMMEND button.

    Please visit my blog to get more information: https://clouddepth.com
    ------------------------------



  • 5.  RE: Connecting to a deployment using SSHSession fails with Unknown Host

    Posted Jun 05, 2025 05:00 AM

    Actually, got it working. We will look into using the Built in SSH workflow - as that's the correct way to do it, but for now to keep our project moving forward, I'll use mine. Not the neatest code but it works. Thanks for your support

    Solution was that the IP address extracted and used for the connection was not being read as a String - so we used toString() and it worked. I guess I could have set that when defining the variable 




  • 6.  RE: Connecting to a deployment using SSHSession fails with Unknown Host

    Posted Jun 05, 2025 05:09 AM

    You're welcome.

    I would suggest to validate the IP address as well. if it is fetch from somewhere. There is a function I wrote to validate my IPs. Feel free to take a look :)



    ------------------------------
    If you find the answer helpful, please click on the RECOMMEND button.

    Please visit my blog to get more information: https://clouddepth.com
    ------------------------------