Octopus Deploy procedure for installing databases and applications

This topic explains how to install the necessary databases and applications through Octopus Deploy.

  1. Install the STS database:
    • Step Template: Package > Deploy a Package
    • Step Name: Install STS DB
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.STSv3.DBInstaller
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  2. Install the DGS database:
    • Step Template: Package > Deploy a Package
    • Step Name: Install DGS DB
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.DocGenServices.DBInstall
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  3. Install the EZ Config Packages and Packets database:
    • Step Template: Package > Deploy a Package
    • Step Name: Install PKGPKT DB
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.PKGPKT.DB
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  4. Install the EZ Config Default Data database:
    • Step Template: Package > Deploy a Package
    • Step Name: Install DefaultData DB
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.DefaultData.DB
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  5. Install the OPPSA database:
    • Step Template: Package > Deploy a Package
    • Step Name: Install OPPSA DB
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.OPPSA.DBInstaller
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  6. Install EDS database:
    • Step Template: Package > Deploy a Package
    • Step Name: Install EDS DB
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.EDS.DBInstaller
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  7. Install the STS application:
    • Step Template: Package > Deploy a Package
    • Step Name: Install STS
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.STSv3.Installer
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  8. Install the DGS application:
    • Step Template: Package > Deploy a Package
    • Step Name: Install DGS
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.DocGenServices.Installer
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  9. Install Expere Document Services:
    • Step Template: Package > Deploy a Package
    • Step Name: Install EDS
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.EDS.Installer
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  10. Install DocumentService
    • Step Template: Package > Deploy a Package
    • Step Name: Install DocumentService
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.DocumentService.Installer
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  11. Install DocViewer:
    • Step Template: Package > Deploy a Package
    • Step Name: Install Docviewer
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: DocViewerInterfaceInstall
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  12. Install EZ Config Packages and Packets:
    • Step Template: Package > Deploy a Package
    • Step Name: Install PKGPKT
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.PKGPKT
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  13. Install EZ Config Default Data:
    • Step Template: Package > Deploy a Package
    • Step Name: Install DefaultData
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.DefaultData
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  14. Install EZ Config Gateway:
    • Step Template: Package > Deploy a Package
    • Step Name: Install EZGateway
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.EZGateway
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  15. Install EZ Config Repost:
    • Step Template: Package > Deploy a Package
    • Step Name: Install EZ Config Repost
    • Service Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.EZConfig.Service
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  16. Install OPPSA:
    • Step Template: Package > Deploy a Package
    • Step Name: Install OPPSA
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.OPPSA.Installer
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  17. Stop Wildfly Service:
    • Step Template: Script > Run a Script
    • Step Name: Stop Wildfly Service
    • Enabled: Yes
    • Execution Location: Run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Script Source: Inline source code
    • Inline Source Code: <below>
    • Referenced Packages: Leave defaults
    • Conditions: Leave defaults
    $wkfs_home = "C:\Program Files\WKFS"
    $deploy_home = $wkfs_home + "\Expere\wildfly-*\standalone\deployments"
    $undeploy_timeout = 60
    $undeploy_sleep = 2
    
    function CheckComplete([string]$folder) {
        $undeploy = Get-ChildItem $folder | Where { $_.Extension -eq ".undeploy" }
        foreach($f in $undeploy) {
            If (-Not (Test-Path (Join-Path $deploy_home ($f -replace ".undeploy",".undeployed" )) )) { return $false }
        }
        return $true
    }
    
    function Terminate([string]$name, [string]$path) {
        $processes = Get-Process | Where-Object {$_.Name -eq $name}
        Foreach($p in $processes)
        {
            if ($p) {
                if (![string]::IsNullOrEmpty($p.Path) -and $p.Path.StartsWith($path))
                {
                    Write-Host "Stopping Process" $p.Name ":" $p.Id
                    Stop-Process -Force -Id $p.Id
                }
            }
        }
    }
    
    function Stop-ServiceWithTimeout ([string] $name, [int] $timeoutSeconds) {
        $timespan = New-Object -TypeName System.Timespan -ArgumentList 0,0,$timeoutSeconds
        $svc = Get-Service -Name $name
        if ($svc -eq $null) { return $false }
        if ($svc.Status -eq [ServiceProcess.ServiceControllerStatus]::Stopped) { return $true }
        try {
            $svc.Stop()
        } 
        catch {
            Write-Verbose "Failed to stop service $($svc.Name)"
            return $false
        }
        try {
            $svc.WaitForStatus([ServiceProcess.ServiceControllerStatus]::Stopped, $timespan)
        }
        catch [ServiceProcess.TimeoutException] {
            Write-Verbose "Timeout stopping service $($svc.Name)"
            return $false
        }
        return $true
    }
    
    # Check if Expere is installed on this server.  if not, exit early
    If (-Not (Test-Path -Path $deploy_home)) {
        Write-Host "Expere was not found."
        Exit
    }
    
    # Undeploy all deployed applications
    Get-ChildItem $deploy_home | where { $_.extension -eq ".undeploy"} | foreach ($_) { Remove-Item $_.fullname}
    Get-ChildItem $deploy_home | Where { $_.Extension -eq ".deployed" } | Rename-Item -NewName { $_.Name -replace ".deployed",".undeploy" }
    
     
    
    # Wait for undeploy to happen but not longer than allocated time
    $start_time = $(Get-Date)
    $allowed_time = New-TimeSpan -Seconds $undeploy_timeout
    Do {
        $elapsed_time = $(Get-Date) - $start_time
        if ($elapsed_time -gt $allowed_time) { Break }
        Start-Sleep $undeploy_sleep
        $complete = CheckComplete -folder $deploy_home
    } While ($complete -eq $false)
    
    If ($count -eq 0) {
        Write-Host "All applications are undeployed."
    } else {
        Write-Host "Max time exceeded waiting for applications to undeploy."
    }
    Get-ChildItem $deploy_home | where { $_.extension -eq ".undeploy"} | foreach ($_) { Remove-Item $_.fullname}
    
    If ((Stop-ServiceWithTimeout -name "WildFly" -timeoutSeconds 60) -eq $true) {
        Write-Host "WildFly service stopped normally."
    } else {
        Write-Host "WildFly service failed to stop."
    }
    
    # Kill java and wildfly-service
    Terminate -name 'java' -path $wkfs_home
    Terminate -name 'wildfly-service' -path $wkfs_home
    
  18. Install Expere:
    • Step Template: Package > Deploy a Package
    • Step Name: Install Expere
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.Expere.Installer
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  19. Install DGS Core:
    • Step Template: Package > Deploy a Package
    • Step Name: Install DGS Core
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.DGSCore.Installer
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults
  20. Install DGS Core DocViewer:
    • Step Template: Package > Deploy a Package
    • Step Name: Install DGS Core DocViewer
    • Enabled: Yes
    • Execution Location: This step will run on each deployment target
    • On Targets in Roles: The role assigned to the deployment targets
    • Package Feed: Your NuGet feed
    • Package ID: WoltersKluwerFS.DGSCore.DocViewer.Api.Installer
    • Configuration Variables: Leave defaults
    • Configuration Transforms: Leave defaults
    • Conditions: Leave defaults