Quantcast
Channel: VMware Communities : All Content - vRealize Automation Tools
Viewing all articles
Browse latest Browse all 9859

PowerShell software component fails despite $LASTEXITCODE = 0

$
0
0

Error at end of software component configure action:

ABORT. Encountered error in Powershell.
Error while executing script: Process exited with an error: 1 (Exit value: 1)

 

Software and versions:

-vRA Version: 7.5.0 (Build: 10053500)

-vSphere Client version 6.7.0.20000

-VM is Windows 2016 Datacenter - Win32NT 10.0.14393.0 Microsoft Windows NT 10.0.14393.0

-chef-solo:

     chef_version=13.2.20

     ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]

-SQL Server 2016 Enterprise Core

-SSMS 2016 Enterprise Core

 

Configurations:

-VMware Guest Agent is installed with software bootstrap on the VM template, downloaded from IaaS server, so it is version 7.5.0.

-"VMware vRealize.....Bootstrap" Windows Service is running under a custom service account that is configured in the admin group for the server.

-Blueprint consists of 1 vSphere machine and contains 1 software component with powershell code in the install and configure action, no reboot specified.

    Install action checks for existence of shared NAS drive (server with file sharing turned on, XServe) and creates PS-drive object.

    Configure action copies files from the share to the E:\ drive of the VM, expands packages to E:\ and C:\, and then executes a chef cookbook that was copied to the c:\chef\cookbooks folder.

-Chef sql cookbook does NOT perform a reboot after sql is installed.

-software component configure action does have the reboot check box checked.

 

Process Flow:

The following is my Try/Catch block, which executes successfully manually running under the same service account the "VMware vRealize.....Bootstrap" Windows Service runs under, on any VM provisioned from the template.

 

It also completes successfully when executed under the vRA software components. SQL is installed, configured, and works successfully.

However, vRA reports exit code 1?

#Execute the DBinstaller to run DBConfigurationScripts
Try{    cd $dbcExpandLoc    $curDir = PWD    Write-Output "LastExitCode BEFORE = $($LASTEXITCODE)"    If($curDir.Path -eq $dbcExpandLoc.Remove($dbcExpandLoc.Length - 1)){        $dbcExecute = E:\00.Install\CareSource.Core.Tools.DatabaseInstaller\DatabaseInstaller.exe deploy -v d -m $dbcExpandLoc$manifestFile -s $server$dbInstance        Write-Output "LastExitCode AFTER = $($LASTEXITCODE)"        $success = $dbcExecute -match "Changed database"
If($dbcExecute){            Write-Output "Success: database script completed."            Write-Output "LastExitCode END = $($LASTEXITCODE)"            exit 0            $LASTEXITCODE = 0        }    } Else {        $errorMsg = "Could not change directories to DatabaseInstaller directory."        Write-Output $errorMsg        exit -1    }
} Catch [Exception] {    $errorMsg = $_.Exception    Write-Output $errorMsg
}
exit 0
$LASTEXITCODE = 0
Write-Output "LastExitCode FINAL = $($LASTEXITCODE)"

 

Here is the output from the vRA provision, there is no other error above, it executes ALL software component configure action powershell code successfully.

 

The sql service gets installed on the VM successfully:

 

3 seconds later there is a WMI warning event gets created:

The Microsoft WMI provider note explains why it records this warning, the sql server installer is spawning a provider in a separate host process running under LocalSystem, which is a security risk triggering the warning.

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/dd315566(v=ws.10)

 

 

This "slightly" answered thread does not apply - vRA Software Components script error  because I am leaving the SQL port as default. The sql service is being installed and configured to run under the same service account as the "VMware vRealize.....Bootstrap" Windows Service. SQL is successfully installed and works fine. However, I read a similar thread that I can't find that indicated that WMI will throw an exit code for the warning.

 

I removed the software components and provisioned a brand new VM, then ran the software components code manually, to see if during the chef solo install of SQL, the WMI event would be created. It was created. I believe the WMI error is somehow bubbling up to vRA as exit code 1 for the script but cannot seem to capture it from the software component code.


Viewing all articles
Browse latest Browse all 9859

Trending Articles