Skip to content

Commit

Permalink
Fix deployment bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Johnston committed Oct 30, 2023
1 parent 90dff47 commit e8373a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
16 changes: 7 additions & 9 deletions cicd/PS-Activate-BLUE.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
$ErrorActionPreference = "Stop"

$CICDPath = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRootPath = Split-Path -Parent $CICDPath
. $RepoRootPath/cicd/PS-Lib.ps1

$RootPassword = Get-AzKeyVaultSecret -VaultName "joeljcakeys" -Name "LinodeRootPasswordWorld1" -AsPlainText

Write-Host -ForegroundColor blue 'In Activate-BLUE'

$CICDPath = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRootPath = Split-Path -Parent $CICDPath

& ${CICDPath}/PS-Get-Certificate-3.ps1 $RepoRootPath
& ${CICDPath}/PS-Get-Certificate-2023.ps1 $RepoRootPath
$NginxConfigContent = & ${CICDPath}/PS-Generate-Nginx-Upstreams.ps1

Out-File -FilePath $RepoRootPath/tmp/joeljca.conf -InputObject $NginxConfigContent
Expand All @@ -16,16 +20,10 @@ $Cmd = "ansible-playbook -i ${CICDPath}/Ansible-Inventory-WORLD1.yml $RepoRootPa

Write-Host $Cmd.Replace($RootPassword, '***')

$Success = Invoke-Expression $Cmd
if (-not $Success){
Write-Error "Command invocation failed"
}
InvokeAndCheck $Cmd

$Cmd = "ansible-playbook -i ${CICDPath}/Ansible-Inventory-WORLD1.yml $RepoRootPath/cicd/Ansible-Playbook-Gateway-Deploy.yml --extra-vars `"root_password=$RootPassword slot=blue`"" + ';$?'

Write-Host $Cmd.Replace($RootPassword, '***')

$Success = Invoke-Expression $Cmd
if (-not $Success){
Write-Error "Command invocation failed"
}
InvokeAndCheck $Cmd
14 changes: 6 additions & 8 deletions cicd/PS-Activate-GREEN.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
$ErrorActionPreference = "Stop"

$CICDPath = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRootPath = Split-Path -Parent $CICDPath
. $RepoRootPath/cicd/PS-Lib.ps1

$RootPassword = Get-AzKeyVaultSecret -VaultName "joeljcakeys" -Name "LinodeRootPasswordWorld1" -AsPlainText

Write-Host -ForegroundColor green 'In Activate-GREEN'
Expand All @@ -16,16 +20,10 @@ $Cmd = "ansible-playbook -i ${CICDPath}/Ansible-Inventory-WORLD1.yml $RepoRootPa

Write-Host $Cmd.Replace($RootPassword, '***')

$Success = Invoke-Expression $Cmd
if (-not $Success){
Write-Error "Command invocation failed"
}
InvokeAndCheck $Cmd

$Cmd = "ansible-playbook -i ${CICDPath}/Ansible-Inventory-WORLD1.yml $RepoRootPath/cicd/Ansible-Playbook-Gateway-Deploy.yml --extra-vars `"root_password=$RootPassword slot=green`"" + ';$?'

Write-Host $Cmd.Replace($RootPassword, '***')

$Success = Invoke-Expression $Cmd
if (-not $Success){
Write-Error "Command invocation failed"
}
InvokeAndCheck $Cmd
2 changes: 1 addition & 1 deletion cicd/PS-Deploy-Main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum NodeHeaderComponents {
}

function GetActiveSlot() {
$SiteVersionHttpRes = Invoke-WebRequest -Uri https://www.joelj.ca/assets/version.txt
$SiteVersionHttpRes = Invoke-WebRequest -Uri https://www.joelj.ca/assets/version.txt -SkipCertificateCheck
$SiteVersionHttpResNodeHeader = $SiteVersionHttpRes.Headers."X-Origin-Node"
$SiteActiveSlot = $SiteVersionHttpResNodeHeader.Split(" ")[[int][NodeHeaderComponents]::slot]
if ($SiteActiveSlot.EndsWith("blue")) {
Expand Down

0 comments on commit e8373a9

Please sign in to comment.