From dd7fda468b139bdad9f93d06d8b35e94db47ecd0 Mon Sep 17 00:00:00 2001 From: matt Date: Tue, 9 Apr 2019 14:26:44 +0100 Subject: [PATCH 01/29] feature/resource-group-param - Created new game server image config job for new standards --- src/Build/ConfigureGSTemplate.ps1 | 266 ++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 src/Build/ConfigureGSTemplate.ps1 diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 new file mode 100644 index 0000000..ca7ad67 --- /dev/null +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -0,0 +1,266 @@ +param( + [switch] $Help = $false, # Allows help to be shown + $azurePassword, # Azure Password + $azureUsername , # i.e: provision-serviceaccount@adminantstream.onmicrosoft.com + $azureSubscriptionName , + $azureResourceGroupName, + $vmName, + $vmAdministratorUsername, + $vmAdministratorPassword, + $gameServerUsername, # CGDeploy Directory USER for demo files. Used by apache. (i.e: cginternal_tOuwMfFmBx8e1OI44SZ7) + $gameServerPassword, # CGDeploy Directory password for demo files. Used by apache. + $aslApiUsername, # CGDeploy ASL API Username. It will be stored in curlparams file. (i.e: ASLVMAPI) + $aslApiPassword, # CGDeploy ASL API Password. It will be stored in curlparams file. + $aslAddress, # ASL URL to use. It will be stored in curlparams and asladdress files. + $emulatorStorageAccount, # Azure storage account name for the emulators + $emulatorAccessKey, # Key for the storage + $emulatorShareName, # name of the share with the emulator + $region, + $environment, + $settingsStorageAccount, + $romStorageAccount, # Region of the VM + $eventHubsKey +) +# Useful links +# Create Linux VM https://azure.microsoft.com/en-gb/documentation/articles/virtual-machines-ps-create-preconfigure-linux-vms +# Create Windows VM https://azure.microsoft.com/en-gb/documentation/articles/virtual-machines-ps-create-preconfigure-windows-vms/ +# VMImages https://azure.microsoft.com/en-gb/blog/vm-image-blog-post/ +# SSH connector http://www.powershelladmin.com/wiki/SSH_from_PowerShell_using_the_SSH.NET_library +# SSH connector http://www.jonathanmedd.net/2013/08/using-ssh-to-access-linux-servers-in-powershell.html + +function Usage() +{ + Write-Host 'Expected parameters:' + Write-Host ' -Help : Shows this help.' + exit 0 +} + +function CopyOverSSHSFTP() +{ + [CmdletBinding()] + param($orig, $destFolder, $ComputerName, $port, $username, $password) + process{ + Write-Host "Copy file $orig to $destFolder in VM $ComputerName using psftp." + dos2unix $orig + Write-Host "Starting copy" + + $program = "..\libraries\putty\psftp.exe" + $cmd = @( + "cd /$destFolder", + "put $orig" + "bye" + ) + # Detect hostkey + $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) + $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry + $output2 = Get-Content "temp.txt" + foreach ($line in $output2) + { + if ($line -like "ssh-rsa 2048 *") + { + $hostkey = $line -replace "ssh-rsa 2048 ","" + Write-Host "Hostkey detected." + } + } + Write-Host "Hostkey=$hostkey." + + # Do the copy with Hostkey + [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) + + Write-Host "Copy finished." + } +} + +function ExecuteSSH($command, $ComputerName, $port, $username, $password, $verbose) +{ + Write-Host "Executing command '$command ' in VM $ComputerName" + $session = Get-SshSession -ComputerName $ComputerName + if ($session.'SSH Connected' -ne "True") + { + #Get-SshSession -ComputerName $ComputerName | ft -AutoSize + Write-Host "Seems that SSH session to $ComputerName was closed. Reopenning" + New-SshSession -ComputerName $ComputerName -Username $username -Password "$password" -Port $port -Reconnect + } + + $result = Invoke-SshCommand -ComputerName $ComputerName -Command "echo $password | sudo -S $command" + if ($verbose) + { + Write-Host $result + } +} + +function dos2unix($file) +{ + Write-Host "Converting file $file from dos format to unix format (dos2unix)" + $x = get-content -raw -path $file + $x -replace "`r`n","`n" | set-content -path $file + Write-Host "Converted." + +} + +function WaitVMToHaveStatus($azureResourceGroupName, $vmName, $desiredStatus, $retrySeconds, [int] $maxNumberRetries) +{ + [bool] $keepPolling = $true + [int] $numberRetries = 0 + while ($keepPolling) + { + Start-Sleep $retrySeconds + $numberRetries++ + $vmstatus = Get-AzureRmVM -ResourceGroupName $azureResourceGroupName -Name $vmName -Status -ErrorAction Ignore + $vmPowerStatus = $vmstatus.Statuses[1].DisplayStatus + if ($vmPowerStatus -eq $desiredStatus) + { + Write-Host "VM Machine $vmName is finally running in $vmPowerStatus state. Attempt $numberRetries" + break + } + else + { + + Write-Host "VM Machine $vmName is not YET running. State = $vmPowerStatus. Attempt $numberRetries" + } + + + if ($numberRetries -gt $maxNumberRetries) + { + throw "Max number of retries exceeded ($numberRetries of maximum $maxNumberRetries attempts) waiting for $VM to get to state $desiredStatus" + } + + } +} + +function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPassword, $port) +{ + [bool] $keepPolling = $true + [int] $numberRetries = 0 + [int] $retrySeconds = 5 + [int] $maxNumberRetries = 100 + + Write-Host "Waiting for SSH." + while ($keepPolling) + { + # Function made by Steve Cottam + New-SshSession -ComputerName $ComputerName -Username $vmAdministratorUsername -Password "$vmAdministratorPassword" -Port $port -Scp -Sftp -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null + $session = Get-SshSession -ComputerName $ComputerName + if (($session.'SSH Connected' -eq "True") -and (($session.'SCP Connected' -eq "True")) -and (($session.'SFTP Connected' -eq "True"))) + { + Write-Host "SSH Connected - closing this connection." + Remove-SshSession -ComputerName $ComputerName + break + } + else + { + + Write-Host "SSH Not Yet Connected. Attempt $numberRetries" + } + + Start-Sleep $retrySeconds + $numberRetries++ + + if ($numberRetries -gt $maxNumberRetries) + { + throw "Max number of retries exceeded ($numberRetries of maximum $maxNumberRetries attempts) waiting for $VM to get to state $desiredStatus" + } + + } +} + + +# Global variables +$scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent +Set-Location $scriptDir +Import-Module ..\modules\remoting.psm1 +Import-Module ..\modules\azure.psm1 + +#Main +$ErrorActionPreference = "Stop" +try +{ + #Preparation steps + $startTime = Get-Date + Write-Host -ForegroundColor Cyan "This deploy GameServer files to templateVM '$vmName'" + Write-Host "Script started ($startTime)" + DetectPowershellVersion 4 + DetectAzurePowerShellVersion + $azurePassword = $azurePassword | ConvertTo-SecureString -asPlainText -Force + $azureCredentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $azureUsername,$azurePassword + Disable-AzureDataCollection -WarningAction SilentlyContinue + + + #1 + Write-Host -ForegroundColor Cyan "Step 1: Logging in to Azure..." + Add-AzureRmAccount -credential $azureCredentials | Out-Null + Write-Host "Logged in." + + #2 + Write-Host -ForegroundColor Cyan "Step 2: Selecting subscription..." + $AzureSub = Select-AzureRmSubscription -SubscriptionName $azureSubscriptionName -Verbose + Write-Host "We are now in $AzureSub.Subscription" + + WaitVMToHaveStatus $azureResourceGroupName $vmName "VM running" 10 180 + + #3 Deploy + Write-Host -ForegroundColor Cyan "Step 3: Connecting via SSH" + Write-Host "Locating VM: $vmName in Resource Group: $azureResourceGroupName" + $vm = Get-AzureRmVM -ResourceGroupName $azureResourceGroupName -Name $vmName + if ($vm -eq $null) { throw "Cannot find VM: $vmName in Resource Group: $azureResourceGroupName" } + + #Detect ComputerName and port + $ComputerName = $vm | Get-AzureRmPublicIPAddress + $ComputerName = $ComputerName.IPAddress + $port = "22" + Write-Host "Detected IP Address of VM $vmName --> $ComputerName" + Write-Host "Detected SSH port: $port" + + $romResourceGroup = "as-${environment}-rg-storage-${region}" + $romSubscription = "as-sub-working" + $settingsResourceGroup = "as-asl-working" + $settingsSubscription = "as-sub-working" + + Write-Host -ForegroundColor Cyan "Step 2: Generating SAS tokens" + + $SettingsStorageAccount = $SettingsStorageAccount.ToLower() + $romStorageAccount = $romStorageAccount.ToLower() + + $romSasKey = GetSasToken $romStorageAccount $romResourceGroup $romSubscription + $settingsSasKey = GetSasToken $SettingsStorageAccount $settingsResourceGroup $settingsSubscription + + Import-Module "..\libraries\SSH-SessionsP\SSH-Sessions" + Write-Host "Connecting to computer: $ComputerName" + WaitForSSH $ComputerName $vmAdministratorUsername $vmAdministratorPassword $port + New-SshSession -ComputerName $ComputerName -Username $vmAdministratorUsername -Password "$vmAdministratorPassword" -Port $port -Scp -Sftp + Write-Host "Connected." + + # Copy Provisioning files and scripts to VM + Write-Host "Copying over assets" + CopyUsingSSHSFTP ".\Provisioning" "/tmp" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword -ErrorAction Continue + + # Update Ubuntu + ExecuteSSH "apt-get update | tee /home/antmin/cgdeploy2.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false + ExecuteSSH 'sudo apt-get -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade | tee /home/antmin/cgdeploy3.log' $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false + ExecuteSSH "cp -v /usr/sbin/waagent.save /usr/sbin/waagent | tee /home/antmin/cgdeploy4.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $true + + # Run the povisioning script + $cgdeployparameters="`"$gameServerUser`" `"$gameServerPassword`" `"$aslAddress`" `"$aslApiUsername`" `"$aslApiPassword`" `"$emulatorStorageAccount`" `"$emulatorAccessKey`" `"$emulatorShareName`" `"$region`" `"$romStorageAccount`" `"$romSasKey`" `"$SettingsStorageAccount`" `"$settingsSasKey`" `"$eventHubsKey`"" + ExecuteSSH "sudo /bin/bash /tmp/Provisioning/base.sh $cgdeployparameters 2>&1 | tee /home/antmin/cgdeploy5.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false + + # Switch off: sudo waagent -deprovision && sudo shutdown -h now + ExecuteSSH "waagent -deprovision+user -force | tee /home/antmin/cgdeploy8.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $true + ExecuteSSH "shutdown -h now | tee /home/antmin/cgdeploy9.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $true + + Remove-SshSession -ComputerName $ComputerName + # END + $endTime = Get-Date + Write-Host "Script finished ($endTime)" + $elapsedTime = new-timespan $startTime $endTime + Write-Host -ForegroundColor Cyan "SUCCESS: Script time = $elapsedTime" + + exit 0 +} +catch [Exception] +{ + Write-Host -ForegroundColor Magenta $psItem.Exception + Write-Host -ForegroundColor Magenta $psItem.ErrorDetails + Write-Host -ForegroundColor Magenta "Error source line:" $psItem.InvocationInfo.ScriptLineNumber + Write-Error -Exception $psItem.Exception + Exit 1 +} From 73947ac4aa4a13ed510f9c3c1d7454784a7552a2 Mon Sep 17 00:00:00 2001 From: matt Date: Tue, 9 Apr 2019 14:54:15 +0100 Subject: [PATCH 02/29] feature/resource-group-param - Switching environment param around --- src/Build/ConfigureGSTemplate.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index ca7ad67..104dcee 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -15,8 +15,8 @@ param( $emulatorStorageAccount, # Azure storage account name for the emulators $emulatorAccessKey, # Key for the storage $emulatorShareName, # name of the share with the emulator - $region, $environment, + $region, $settingsStorageAccount, $romStorageAccount, # Region of the VM $eventHubsKey From 385d1f928110aa113b85feac11626cd3e01cded9 Mon Sep 17 00:00:00 2001 From: matt Date: Tue, 9 Apr 2019 15:42:10 +0100 Subject: [PATCH 03/29] feature/resource-group-param - Convert tabs to spaces --- src/Build/ConfigureGSTemplate.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 104dcee..f163854 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -132,19 +132,19 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas { [bool] $keepPolling = $true [int] $numberRetries = 0 - [int] $retrySeconds = 5 - [int] $maxNumberRetries = 100 + [int] $retrySeconds = 5 + [int] $maxNumberRetries = 100 Write-Host "Waiting for SSH." while ($keepPolling) { # Function made by Steve Cottam - New-SshSession -ComputerName $ComputerName -Username $vmAdministratorUsername -Password "$vmAdministratorPassword" -Port $port -Scp -Sftp -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null + New-SshSession -ComputerName $ComputerName -Username $vmAdministratorUsername -Password "$vmAdministratorPassword" -Port $port -Scp -Sftp -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null $session = Get-SshSession -ComputerName $ComputerName - if (($session.'SSH Connected' -eq "True") -and (($session.'SCP Connected' -eq "True")) -and (($session.'SFTP Connected' -eq "True"))) + if (($session.'SSH Connected' -eq "True") -and (($session.'SCP Connected' -eq "True")) -and (($session.'SFTP Connected' -eq "True"))) { Write-Host "SSH Connected - closing this connection." - Remove-SshSession -ComputerName $ComputerName + Remove-SshSession -ComputerName $ComputerName break } else @@ -183,7 +183,7 @@ try DetectAzurePowerShellVersion $azurePassword = $azurePassword | ConvertTo-SecureString -asPlainText -Force $azureCredentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $azureUsername,$azurePassword - Disable-AzureDataCollection -WarningAction SilentlyContinue + Disable-AzureDataCollection -WarningAction SilentlyContinue #1 @@ -248,8 +248,8 @@ try ExecuteSSH "shutdown -h now | tee /home/antmin/cgdeploy9.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $true Remove-SshSession -ComputerName $ComputerName - # END - $endTime = Get-Date + # END + $endTime = Get-Date Write-Host "Script finished ($endTime)" $elapsedTime = new-timespan $startTime $endTime Write-Host -ForegroundColor Cyan "SUCCESS: Script time = $elapsedTime" From c11c644e620d38f51b7d721438cb68cd1fdcfd37 Mon Sep 17 00:00:00 2001 From: matt Date: Tue, 9 Apr 2019 16:16:41 +0100 Subject: [PATCH 04/29] feature/resource-group-param - Fixing module path --- src/Build/ConfigureGSTemplate.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index f163854..57cc7a9 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -168,8 +168,8 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas # Global variables $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent Set-Location $scriptDir -Import-Module ..\modules\remoting.psm1 -Import-Module ..\modules\azure.psm1 +Import-Module ..\..\modules\remoting.psm1 +Import-Module ..\..\modules\azure.psm1 #Main $ErrorActionPreference = "Stop" From bbde251a1da735bada85b77335c2398475fcec75 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 10:16:21 +0100 Subject: [PATCH 05/29] feature/resource-group-param - Correcting module import, and putting with rest --- src/Build/ConfigureGSTemplate.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 57cc7a9..eb95302 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -14,7 +14,7 @@ param( $aslAddress, # ASL URL to use. It will be stored in curlparams and asladdress files. $emulatorStorageAccount, # Azure storage account name for the emulators $emulatorAccessKey, # Key for the storage - $emulatorShareName, # name of the share with the emulator + $emulatorShareName, # nameSSH-Sessions of the share with the emulator $environment, $region, $settingsStorageAccount, @@ -170,6 +170,7 @@ $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent Set-Location $scriptDir Import-Module ..\..\modules\remoting.psm1 Import-Module ..\..\modules\azure.psm1 +Import-Module ..\..\libraries\SSH-SessionsP\SSH-Sessions #Main $ErrorActionPreference = "Stop" @@ -224,7 +225,6 @@ try $romSasKey = GetSasToken $romStorageAccount $romResourceGroup $romSubscription $settingsSasKey = GetSasToken $SettingsStorageAccount $settingsResourceGroup $settingsSubscription - Import-Module "..\libraries\SSH-SessionsP\SSH-Sessions" Write-Host "Connecting to computer: $ComputerName" WaitForSSH $ComputerName $vmAdministratorUsername $vmAdministratorPassword $port New-SshSession -ComputerName $ComputerName -Username $vmAdministratorUsername -Password "$vmAdministratorPassword" -Port $port -Scp -Sftp From ad922e10f5734b271df5ee632c46ee896faceb2d Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 10:30:04 +0100 Subject: [PATCH 06/29] feature/resource-group-param - Correcting program import command --- src/Build/ConfigureGSTemplate.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index eb95302..4b17200 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -44,7 +44,7 @@ function CopyOverSSHSFTP() dos2unix $orig Write-Host "Starting copy" - $program = "..\libraries\putty\psftp.exe" + $program = "..\..\libraries\putty\psftp.exe" $cmd = @( "cd /$destFolder", "put $orig" From 60b4656c2c1885e66ce84bec3adf691a1000400e Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 10:43:08 +0100 Subject: [PATCH 07/29] feature/resource-group-param - More logging --- src/Build/ConfigureGSTemplate.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 4b17200..2b1d8bd 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -43,7 +43,7 @@ function CopyOverSSHSFTP() Write-Host "Copy file $orig to $destFolder in VM $ComputerName using psftp." dos2unix $orig Write-Host "Starting copy" - + Write-Host "..\..\libraries\putty\psftp.exe" $program = "..\..\libraries\putty\psftp.exe" $cmd = @( "cd /$destFolder", @@ -217,7 +217,7 @@ try $settingsResourceGroup = "as-asl-working" $settingsSubscription = "as-sub-working" - Write-Host -ForegroundColor Cyan "Step 2: Generating SAS tokens" + Write-Host -ForegroundColor Cyan "Step 4: Generating SAS tokens" $SettingsStorageAccount = $SettingsStorageAccount.ToLower() $romStorageAccount = $romStorageAccount.ToLower() From 0c9c14b8f23e5990e13e105e73371bf42aee362f Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 11:21:31 +0100 Subject: [PATCH 08/29] feature/resource-group-param - Removing unused func and trying to set a consistent location for SFTP copy --- modules/remoting.psm1 | 8 +++++++ src/Build/ConfigureGSTemplate.ps1 | 36 ------------------------------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/modules/remoting.psm1 b/modules/remoting.psm1 index b08e55c..b24b2a3 100644 --- a/modules/remoting.psm1 +++ b/modules/remoting.psm1 @@ -20,6 +20,12 @@ function CopyUsingSSHSFTP { Write-Host "Copy $orig to $destFolder in VM $ComputerName using psftp." #dos2unix $orig Write-Host "Starting copy" + $oldLocation = Get-Location + + $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent + + Write-Host "Setting location to ${scriptDir}" + Set-Location $scriptDir $program = "..\libraries\putty\psftp.exe" $cmd = @( @@ -45,4 +51,6 @@ function CopyUsingSSHSFTP { [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) Write-Host "Copy finished." + + Set-Location $oldLocation } diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 2b1d8bd..23ec7a8 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -35,42 +35,6 @@ function Usage() exit 0 } -function CopyOverSSHSFTP() -{ - [CmdletBinding()] - param($orig, $destFolder, $ComputerName, $port, $username, $password) - process{ - Write-Host "Copy file $orig to $destFolder in VM $ComputerName using psftp." - dos2unix $orig - Write-Host "Starting copy" - Write-Host "..\..\libraries\putty\psftp.exe" - $program = "..\..\libraries\putty\psftp.exe" - $cmd = @( - "cd /$destFolder", - "put $orig" - "bye" - ) - # Detect hostkey - $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) - $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry - $output2 = Get-Content "temp.txt" - foreach ($line in $output2) - { - if ($line -like "ssh-rsa 2048 *") - { - $hostkey = $line -replace "ssh-rsa 2048 ","" - Write-Host "Hostkey detected." - } - } - Write-Host "Hostkey=$hostkey." - - # Do the copy with Hostkey - [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) - - Write-Host "Copy finished." - } -} - function ExecuteSSH($command, $ComputerName, $port, $username, $password, $verbose) { Write-Host "Executing command '$command ' in VM $ComputerName" From a72e014692a616541fa169042a6cec7a5269b4cf Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 12:31:57 +0100 Subject: [PATCH 09/29] feature/resource-group-param - Bringing module sftp function into templat config job --- modules/remoting.psm1 | 8 ------- src/Build/ConfigureGSTemplate.ps1 | 40 ++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/modules/remoting.psm1 b/modules/remoting.psm1 index b24b2a3..b08e55c 100644 --- a/modules/remoting.psm1 +++ b/modules/remoting.psm1 @@ -20,12 +20,6 @@ function CopyUsingSSHSFTP { Write-Host "Copy $orig to $destFolder in VM $ComputerName using psftp." #dos2unix $orig Write-Host "Starting copy" - $oldLocation = Get-Location - - $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent - - Write-Host "Setting location to ${scriptDir}" - Set-Location $scriptDir $program = "..\libraries\putty\psftp.exe" $cmd = @( @@ -51,6 +45,4 @@ function CopyUsingSSHSFTP { [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) Write-Host "Copy finished." - - Set-Location $oldLocation } diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 23ec7a8..91e0c4b 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -128,11 +128,49 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas } } +function CopyUsingSSHSFTP { + param ( + $orig, + $destFolder, + $ComputerName, + $port, + $username, + $password + ) + + Write-Host "Copy $orig to $destFolder in VM $ComputerName using psftp." + #dos2unix $orig + Write-Host "Starting copy" + + $program = "..\libraries\putty\psftp.exe" + $cmd = @( + "cd /$destFolder", + "put -r $orig" + "bye" + ) + # Detect hostkey + $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) + $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry + $output2 = Get-Content "temp.txt" + foreach ($line in $output2) + { + if ($line -like "ssh-rsa 2048 *") + { + $hostkey = $line -replace "ssh-rsa 2048 ","" + Write-Host "Hostkey detected." + } + } + Write-Host "Hostkey=$hostkey." + + # Do the copy with Hostkey + [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) + + Write-Host "Copy finished." +} # Global variables $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent Set-Location $scriptDir -Import-Module ..\..\modules\remoting.psm1 Import-Module ..\..\modules\azure.psm1 Import-Module ..\..\libraries\SSH-SessionsP\SSH-Sessions From 8f53ec39fd335e79e85ffdd27670ed6690cc4f9a Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 12:32:23 +0100 Subject: [PATCH 10/29] feature/resource-group-param - Bringing module sftp function into templat config job --- modules/remoting.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/remoting.psm1 b/modules/remoting.psm1 index b08e55c..5fbfb7c 100644 --- a/modules/remoting.psm1 +++ b/modules/remoting.psm1 @@ -21,7 +21,7 @@ function CopyUsingSSHSFTP { #dos2unix $orig Write-Host "Starting copy" - $program = "..\libraries\putty\psftp.exe" + $program = "..\..\libraries\putty\psftp.exe" $cmd = @( "cd /$destFolder", "put -r $orig" From 43f9734f25c2dacd3f9e4d77fc75f25d1448406d Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 12:58:49 +0100 Subject: [PATCH 11/29] feature/resource-group-param - Trying different method of importing module --- modules/remoting.psm1 | 2 +- src/Build/ConfigureGSTemplate.ps1 | 49 +++++-------------------------- 2 files changed, 8 insertions(+), 43 deletions(-) diff --git a/modules/remoting.psm1 b/modules/remoting.psm1 index 5fbfb7c..b08e55c 100644 --- a/modules/remoting.psm1 +++ b/modules/remoting.psm1 @@ -21,7 +21,7 @@ function CopyUsingSSHSFTP { #dos2unix $orig Write-Host "Starting copy" - $program = "..\..\libraries\putty\psftp.exe" + $program = "..\libraries\putty\psftp.exe" $cmd = @( "cd /$destFolder", "put -r $orig" diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 91e0c4b..aa30334 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -128,51 +128,16 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas } } -function CopyUsingSSHSFTP { - param ( - $orig, - $destFolder, - $ComputerName, - $port, - $username, - $password - ) - - Write-Host "Copy $orig to $destFolder in VM $ComputerName using psftp." - #dos2unix $orig - Write-Host "Starting copy" - - $program = "..\libraries\putty\psftp.exe" - $cmd = @( - "cd /$destFolder", - "put -r $orig" - "bye" - ) - # Detect hostkey - $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) - $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry - $output2 = Get-Content "temp.txt" - foreach ($line in $output2) - { - if ($line -like "ssh-rsa 2048 *") - { - $hostkey = $line -replace "ssh-rsa 2048 ","" - Write-Host "Hostkey detected." - } - } - Write-Host "Hostkey=$hostkey." - - # Do the copy with Hostkey - [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) - - Write-Host "Copy finished." -} - # Global variables $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent Set-Location $scriptDir -Import-Module ..\..\modules\azure.psm1 -Import-Module ..\..\libraries\SSH-SessionsP\SSH-Sessions + +$moduleDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($scriptDir, "..\..\modules\")) +$libraryDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($scriptDir, "..\..\libraries\")) + +Import-Module "$moduleDir\azure.psm1" -Force +Import-Module "$moduleDir\remoting.psm1" -Force +Import-Module "$libraryDir\SSH-SessionsP\SSH-Sessions" -Force #Main $ErrorActionPreference = "Stop" From ea7373603333ff56be53b2342b0a26a5f521728d Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 13:43:22 +0100 Subject: [PATCH 12/29] feature/resource-group-param - Trying to fix relative paths --- modules/remoting.psm1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/remoting.psm1 b/modules/remoting.psm1 index b08e55c..41209ce 100644 --- a/modules/remoting.psm1 +++ b/modules/remoting.psm1 @@ -21,7 +21,11 @@ function CopyUsingSSHSFTP { #dos2unix $orig Write-Host "Starting copy" - $program = "..\libraries\putty\psftp.exe" + $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent + Set-Location $scriptDir + $libraryDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($scriptDir, "..\..\libraries\")) + $program = "$libraryDir\putty\psftp.exe" + $cmd = @( "cd /$destFolder", "put -r $orig" From ccf2e2c2cc77a20b2a2782da7cbc415ec7f4e979 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 13:57:52 +0100 Subject: [PATCH 13/29] feature/resource-group-param - Duping function as remoting module is inoperable --- modules/remoting.psm1 | 6 +---- src/Build/ConfigureGSTemplate.ps1 | 41 ++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/modules/remoting.psm1 b/modules/remoting.psm1 index 41209ce..b08e55c 100644 --- a/modules/remoting.psm1 +++ b/modules/remoting.psm1 @@ -21,11 +21,7 @@ function CopyUsingSSHSFTP { #dos2unix $orig Write-Host "Starting copy" - $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent - Set-Location $scriptDir - $libraryDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($scriptDir, "..\..\libraries\")) - $program = "$libraryDir\putty\psftp.exe" - + $program = "..\libraries\putty\psftp.exe" $cmd = @( "cd /$destFolder", "put -r $orig" diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index aa30334..067d255 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -128,6 +128,46 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas } } +function CopyUsingSSHSFTP { + param ( + $orig, + $destFolder, + $ComputerName, + $port, + $username, + $password + ) + + Write-Host "Copy $orig to $destFolder in VM $ComputerName using psftp." + #dos2unix $orig + Write-Host "Starting copy" + + $program = "....\\libraries\putty\psftp.exe" + $cmd = @( + "cd /$destFolder", + "put -r $orig" + "bye" + ) + # Detect hostkey + $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) + $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry + $output2 = Get-Content "temp.txt" + foreach ($line in $output2) + { + if ($line -like "ssh-rsa 2048 *") + { + $hostkey = $line -replace "ssh-rsa 2048 ","" + Write-Host "Hostkey detected." + } + } + Write-Host "Hostkey=$hostkey." + + # Do the copy with Hostkey + [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) + + Write-Host "Copy finished." +} + # Global variables $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent Set-Location $scriptDir @@ -136,7 +176,6 @@ $moduleDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($scriptDir, $libraryDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($scriptDir, "..\..\libraries\")) Import-Module "$moduleDir\azure.psm1" -Force -Import-Module "$moduleDir\remoting.psm1" -Force Import-Module "$libraryDir\SSH-SessionsP\SSH-Sessions" -Force #Main From d822d1b38ae4c851e7e9f8a758e5b00d917507c8 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 14:06:04 +0100 Subject: [PATCH 14/29] feature/resource-group-param - Fixing path error --- src/Build/ConfigureGSTemplate.ps1 | 56 +++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 067d255..a8bcc4e 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -138,34 +138,34 @@ function CopyUsingSSHSFTP { $password ) - Write-Host "Copy $orig to $destFolder in VM $ComputerName using psftp." - #dos2unix $orig - Write-Host "Starting copy" - - $program = "....\\libraries\putty\psftp.exe" - $cmd = @( - "cd /$destFolder", - "put -r $orig" - "bye" - ) - # Detect hostkey - $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) - $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry - $output2 = Get-Content "temp.txt" - foreach ($line in $output2) - { - if ($line -like "ssh-rsa 2048 *") - { - $hostkey = $line -replace "ssh-rsa 2048 ","" - Write-Host "Hostkey detected." - } - } - Write-Host "Hostkey=$hostkey." - - # Do the copy with Hostkey - [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) - - Write-Host "Copy finished." + Write-Host "Copy $orig to $destFolder in VM $ComputerName using psftp." + #dos2unix $orig + Write-Host "Starting copy" + + $program = "..\..\libraries\putty\psftp.exe" + $cmd = @( + "cd /$destFolder", + "put -r $orig" + "bye" + ) + # Detect hostkey + $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) + $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry + $output2 = Get-Content "temp.txt" + foreach ($line in $output2) + { + if ($line -like "ssh-rsa 2048 *") + { + $hostkey = $line -replace "ssh-rsa 2048 ","" + Write-Host "Hostkey detected." + } + } + Write-Host "Hostkey=$hostkey." + + # Do the copy with Hostkey + [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) + + Write-Host "Copy finished." } # Global variables From 3287d113873ccba9345b16d712ca4c18a85638b2 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 14:34:25 +0100 Subject: [PATCH 15/29] feature/resource-group-param - Trying to output contents --- src/Build/ConfigureGSTemplate.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index a8bcc4e..16068df 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -151,7 +151,9 @@ function CopyUsingSSHSFTP { # Detect hostkey $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry - $output2 = Get-Content "temp.txt" + $output2 = Get-Content "..\temp.txt" + Write-Host "File Contents: " + Write-Host $output2 foreach ($line in $output2) { if ($line -like "ssh-rsa 2048 *") From 8f0d6407b62b191475e9f296207a2f5cfc822e33 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 14:40:33 +0100 Subject: [PATCH 16/29] feature/resource-group-param - Forcing use of correct function --- src/Build/ConfigureGSTemplate.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 16068df..e75376f 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -128,7 +128,7 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas } } -function CopyUsingSSHSFTP { +function CopyWithSSHSFTP { param ( $orig, $destFolder, @@ -151,7 +151,7 @@ function CopyUsingSSHSFTP { # Detect hostkey $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry - $output2 = Get-Content "..\temp.txt" + $output2 = Get-Content "temp.txt" Write-Host "File Contents: " Write-Host $output2 foreach ($line in $output2) @@ -240,7 +240,7 @@ try # Copy Provisioning files and scripts to VM Write-Host "Copying over assets" - CopyUsingSSHSFTP ".\Provisioning" "/tmp" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword -ErrorAction Continue + CopyWithSSHSFTP ".\Provisioning" "/tmp" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword -ErrorAction Continue # Update Ubuntu ExecuteSSH "apt-get update | tee /home/antmin/cgdeploy2.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false From 88a46ef3f6fc0c2c3417ca861ffbf15dc5b14dea Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 14:47:07 +0100 Subject: [PATCH 17/29] feature/resource-group-param - Test write --- src/Build/ConfigureGSTemplate.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index e75376f..9141407 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -148,6 +148,8 @@ function CopyWithSSHSFTP { "put -r $orig" "bye" ) + + Write-Host "Test copy" # Detect hostkey $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry From 44ec150d78d4dec36f96ce0ecf07f2217ccac517 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 10 Apr 2019 17:32:12 +0100 Subject: [PATCH 18/29] feature/resource-group-param - Various clean ups and fixes for the ConfigureGSTemplate job --- modules/remoting-alt.psm1 | 48 +++++++++++++++++++++++ src/Build/ConfigureGSTemplate.ps1 | 65 +++++++++---------------------- 2 files changed, 67 insertions(+), 46 deletions(-) create mode 100644 modules/remoting-alt.psm1 diff --git a/modules/remoting-alt.psm1 b/modules/remoting-alt.psm1 new file mode 100644 index 0000000..8de066d --- /dev/null +++ b/modules/remoting-alt.psm1 @@ -0,0 +1,48 @@ +function CopyUsingSSHSFTP { +#will recurse switch break single files? + <# + .Synopsis + Copy files and folders from source to destination server + + .Example + DownloadAzureStorageBlob $StorageAccountName $StorageAccountKey $Destination; + #> + [CmdletBinding()] + param ( + $orig, + $destFolder, + $ComputerName, + $port, + $username, + $password + ) + + Write-Host "Copy $orig to $destFolder in VM $ComputerName using psftp." + #dos2unix $orig + Write-Host "Starting copy" + + $program = "..\..\libraries\putty\psftp.exe" + $cmd = @( + "cd /$destFolder", + "put -r $orig" + "bye" + ) + # Detect hostkey + $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) + $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry + $output2 = Get-Content "temp.txt" + foreach ($line in $output2) + { + if ($line -like "ssh-rsa 2048 *") + { + $hostkey = $line -replace "ssh-rsa 2048 ","" + Write-Host "Hostkey detected." + } + } + Write-Host "Hostkey=$hostkey." + + # Do the copy with Hostkey + [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) + + Write-Host "Copy finished." +} diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 9141407..780a280 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -128,50 +128,6 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas } } -function CopyWithSSHSFTP { - param ( - $orig, - $destFolder, - $ComputerName, - $port, - $username, - $password - ) - - Write-Host "Copy $orig to $destFolder in VM $ComputerName using psftp." - #dos2unix $orig - Write-Host "Starting copy" - - $program = "..\..\libraries\putty\psftp.exe" - $cmd = @( - "cd /$destFolder", - "put -r $orig" - "bye" - ) - - Write-Host "Test copy" - # Detect hostkey - $output1 = [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" 2>&1 ) - $output1 | Out-File "temp.txt" -Force # It is horrible but I am in a hurry - $output2 = Get-Content "temp.txt" - Write-Host "File Contents: " - Write-Host $output2 - foreach ($line in $output2) - { - if ($line -like "ssh-rsa 2048 *") - { - $hostkey = $line -replace "ssh-rsa 2048 ","" - Write-Host "Hostkey detected." - } - } - Write-Host "Hostkey=$hostkey." - - # Do the copy with Hostkey - [String]($cmd | & $program -batch -pw $password "$username@$ComputerName" -hostkey $hostkey 2>&1 ) - - Write-Host "Copy finished." -} - # Global variables $scriptDir = Split-Path ($MyInvocation.MyCommand.Definition) -parent Set-Location $scriptDir @@ -181,6 +137,13 @@ $libraryDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($scriptDir Import-Module "$moduleDir\azure.psm1" -Force Import-Module "$libraryDir\SSH-SessionsP\SSH-Sessions" -Force +Import-Module "$moduleDir\remoting-alt.psm1" -Force #I can only apologise for this file existing + +$scpInstalled = Get-Module -ListAvailable -Name Posh-SSH +if (-Not $scpInstalled) { + Install-PackageProvider NuGet -Force + Import-PackageProvider NuGet -Force +} #Main $ErrorActionPreference = "Stop" @@ -196,7 +159,6 @@ try $azureCredentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $azureUsername,$azurePassword Disable-AzureDataCollection -WarningAction SilentlyContinue - #1 Write-Host -ForegroundColor Cyan "Step 1: Logging in to Azure..." Add-AzureRmAccount -credential $azureCredentials | Out-Null @@ -242,8 +204,19 @@ try # Copy Provisioning files and scripts to VM Write-Host "Copying over assets" - CopyWithSSHSFTP ".\Provisioning" "/tmp" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword -ErrorAction Continue + CopyUsingSSHSFTP "..\Provisioning" "/tmp" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword -ErrorAction Continue + #$vmAdministratorPassword = $vmAdministratorPassword | ConvertTo-SecureString -asPlainText -Force + #$sftpCredentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $vmAdministratorUsername,$vmAdministratorPassword + #$ThisSession = New-SFTPSession -ComputerName $ComputerName -Credential $sftpCredentials + + #$parentPath = Split-Path $PSScriptRoot -Parent + #$localFolder = "$parentPath/Provisioning" + #Set-ScpFolder -ComputerName $computerName -Credential $scpCredentials -RemoteFolder '/tmp' -LocalFolder $localFolder + #Set-SFTPFolder -SessionId ($ThisSession).SessionId -RemoteFolder '/tmp' -LocalFolder "./../Provisioning" + #Set-SFTPFile -SessionId ($ThisSession).SessionId -RemotePath '/tmp' -LocalFile "./../Provisioning" -Recursive + + #Get-SFTPSession | % { Remove-SFTPSession -SessionId ($_.SessionId) } # Update Ubuntu ExecuteSSH "apt-get update | tee /home/antmin/cgdeploy2.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false ExecuteSSH 'sudo apt-get -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade | tee /home/antmin/cgdeploy3.log' $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false From 915cdf143ade0f7ac8c359d0473257cee4381fac Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 11 Apr 2019 13:03:14 +0100 Subject: [PATCH 19/29] feature/resource-group-param - Removing eventhubs key param --- src/Build/ConfigureGSTemplate.ps1 | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 780a280..2e29040 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -16,10 +16,9 @@ param( $emulatorAccessKey, # Key for the storage $emulatorShareName, # nameSSH-Sessions of the share with the emulator $environment, - $region, + $region, # Region of the VM $settingsStorageAccount, - $romStorageAccount, # Region of the VM - $eventHubsKey + $romStorageAccount ) # Useful links # Create Linux VM https://azure.microsoft.com/en-gb/documentation/articles/virtual-machines-ps-create-preconfigure-linux-vms @@ -83,12 +82,10 @@ function WaitVMToHaveStatus($azureResourceGroupName, $vmName, $desiredStatus, $r Write-Host "VM Machine $vmName is not YET running. State = $vmPowerStatus. Attempt $numberRetries" } - if ($numberRetries -gt $maxNumberRetries) { throw "Max number of retries exceeded ($numberRetries of maximum $maxNumberRetries attempts) waiting for $VM to get to state $desiredStatus" } - } } @@ -157,7 +154,7 @@ try DetectAzurePowerShellVersion $azurePassword = $azurePassword | ConvertTo-SecureString -asPlainText -Force $azureCredentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $azureUsername,$azurePassword - Disable-AzureDataCollection -WarningAction SilentlyContinue + Disable-AzureDataCollection -WarningAction SilentlyContinue #1 Write-Host -ForegroundColor Cyan "Step 1: Logging in to Azure..." @@ -197,6 +194,12 @@ try $romSasKey = GetSasToken $romStorageAccount $romResourceGroup $romSubscription $settingsSasKey = GetSasToken $SettingsStorageAccount $settingsResourceGroup $settingsSubscription + Write-Host -ForegroundColor Cyan "Getting Eventhubs Key" + $eventHubResourceGroupName = "as-$environment-rg-logs-GLOBAL" + $eventHubNameSpaceName = "as-$environment-eh-logs-$region" + + $eventHubsKey = (Get-AzureRmEventHubKey -ResourceGroupName $eventHubResourceGroupName -Namespace $eventHubNameSpaceName -Name "RootManageSharedAccessKey").PrimaryKey + Write-Host "Connecting to computer: $ComputerName" WaitForSSH $ComputerName $vmAdministratorUsername $vmAdministratorPassword $port New-SshSession -ComputerName $ComputerName -Username $vmAdministratorUsername -Password "$vmAdministratorPassword" -Port $port -Scp -Sftp @@ -206,17 +209,7 @@ try Write-Host "Copying over assets" CopyUsingSSHSFTP "..\Provisioning" "/tmp" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword -ErrorAction Continue - #$vmAdministratorPassword = $vmAdministratorPassword | ConvertTo-SecureString -asPlainText -Force - #$sftpCredentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $vmAdministratorUsername,$vmAdministratorPassword - #$ThisSession = New-SFTPSession -ComputerName $ComputerName -Credential $sftpCredentials - - #$parentPath = Split-Path $PSScriptRoot -Parent - #$localFolder = "$parentPath/Provisioning" - #Set-ScpFolder -ComputerName $computerName -Credential $scpCredentials -RemoteFolder '/tmp' -LocalFolder $localFolder - #Set-SFTPFolder -SessionId ($ThisSession).SessionId -RemoteFolder '/tmp' -LocalFolder "./../Provisioning" - #Set-SFTPFile -SessionId ($ThisSession).SessionId -RemotePath '/tmp' -LocalFile "./../Provisioning" -Recursive - #Get-SFTPSession | % { Remove-SFTPSession -SessionId ($_.SessionId) } # Update Ubuntu ExecuteSSH "apt-get update | tee /home/antmin/cgdeploy2.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false ExecuteSSH 'sudo apt-get -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade | tee /home/antmin/cgdeploy3.log' $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false @@ -231,8 +224,8 @@ try ExecuteSSH "shutdown -h now | tee /home/antmin/cgdeploy9.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $true Remove-SshSession -ComputerName $ComputerName - # END - $endTime = Get-Date + # END + v $endTime = Get-Date Write-Host "Script finished ($endTime)" $elapsedTime = new-timespan $startTime $endTime Write-Host -ForegroundColor Cyan "SUCCESS: Script time = $elapsedTime" From 22aaaef14c5f442a33ada31238531d0f2a6d2239 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 11 Apr 2019 14:07:59 +0100 Subject: [PATCH 20/29] feature/resource-group-param - Removing typo --- src/Build/ConfigureGSTemplate.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 2e29040..4f12c09 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -225,7 +225,7 @@ try Remove-SshSession -ComputerName $ComputerName # END - v $endTime = Get-Date + $endTime = Get-Date Write-Host "Script finished ($endTime)" $elapsedTime = new-timespan $startTime $endTime Write-Host -ForegroundColor Cyan "SUCCESS: Script time = $elapsedTime" From 7779e0a6c91e7b60ff86319b42c8e2b0b29c470c Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 11 Apr 2019 14:26:07 +0100 Subject: [PATCH 21/29] feature/resource-group-param - Fixing username param --- src/Build/ConfigureGSTemplate.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 4f12c09..cea36f3 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -216,7 +216,7 @@ try ExecuteSSH "cp -v /usr/sbin/waagent.save /usr/sbin/waagent | tee /home/antmin/cgdeploy4.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $true # Run the povisioning script - $cgdeployparameters="`"$gameServerUser`" `"$gameServerPassword`" `"$aslAddress`" `"$aslApiUsername`" `"$aslApiPassword`" `"$emulatorStorageAccount`" `"$emulatorAccessKey`" `"$emulatorShareName`" `"$region`" `"$romStorageAccount`" `"$romSasKey`" `"$SettingsStorageAccount`" `"$settingsSasKey`" `"$eventHubsKey`"" + $cgdeployparameters="`"$gameServerUsername`" `"$gameServerPassword`" `"$aslAddress`" `"$aslApiUsername`" `"$aslApiPassword`" `"$emulatorStorageAccount`" `"$emulatorAccessKey`" `"$emulatorShareName`" `"$region`" `"$romStorageAccount`" `"$romSasKey`" `"$SettingsStorageAccount`" `"$settingsSasKey`" `"$eventHubsKey`"" ExecuteSSH "sudo /bin/bash /tmp/Provisioning/base.sh $cgdeployparameters 2>&1 | tee /home/antmin/cgdeploy5.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false # Switch off: sudo waagent -deprovision && sudo shutdown -h now From 44fe0ab56c71b31788cd035a50a6f3b3dbc31a59 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 11 Apr 2019 17:32:36 +0100 Subject: [PATCH 22/29] feature/resource-group-param - Starting to move resources out to pre-set values instead of params --- modules/resource-locator.psm1 | 63 ++++++++++ modules/telegraf.conf | 193 ++++++++++++++++++++++++++++++ src/Build/ConfigureGSTemplate.ps1 | 17 +-- 3 files changed, 266 insertions(+), 7 deletions(-) create mode 100644 modules/resource-locator.psm1 create mode 100644 modules/telegraf.conf diff --git a/modules/resource-locator.psm1 b/modules/resource-locator.psm1 new file mode 100644 index 0000000..7f7b1da --- /dev/null +++ b/modules/resource-locator.psm1 @@ -0,0 +1,63 @@ +<# + .SYNOPSIS + Functions that return locations of external resources that comply with our new naming convention/ + This is basically a dynamic config file + Author: Matthew Tyas +#> + +#Azure Resources +function GetVMImageName($environment, $branch) +{ + return "GameServerBaseImage_${environment}_${branch}" +} + +function GetVmName($environment) +{ + return "as-gstemplate-$environment" +} + +function GetASLAddress($environment, $region) +{ + return "https://as-${environment}-asl-${region}.azurewebsites.net/api" +} + +function GetVirtualNetwork($environment, $region) +{ + return "as-${environment}-vnet-GS-${region}" +} + +function GetNetworkSecurityGroupName($environment) +{ + return "as-${environment}-nsg-GS" +} + +function GetAzureResourceGroupName($environment, $region) +{ + return "as-${environment}-rg-GS-${region}" +} +# Storage Accounts + +function GetImageStorageAccount($environment, $region) +{ + return "as${environment}rggs${region}disks01" +} + +function GetDiagnosticsStorageAccountName($environment, $region) +{ + return "as${environment}rggs${region}diag01" +} + +function GetEmulatorStorageAccount($environment, $region) +{ + return "as${environment}storage${region}" +} + +function GetGameSettingsStorageAccount() +{ + return "asdevblob" +} + +function GetRomStorageAccount($environment, $region) +{ + return "as${environment}storage${region}" +} diff --git a/modules/telegraf.conf b/modules/telegraf.conf new file mode 100644 index 0000000..715475b --- /dev/null +++ b/modules/telegraf.conf @@ -0,0 +1,193 @@ +[agent] + interval = "10s" + round_interval = true + metric_batch_size = 1000 + metric_buffer_limit = 10000 + collection_jitter = "0s" + flush_jitter = "0s" + precision = "" + debug = false + quiet = false + # Disable logging, this is stops it complaining about procstat being unable to find apps + logfile = "/dev/null" # + + hostname = "" + omit_hostname = false + +[[outputs.influxdb]] + urls = ["http://as-sql-influxdb.northeurope.cloudapp.azure.com:8086"] # required + database = "machine_stats" # required + + retention_policy = "high_stats" + write_consistency = "any" + + timeout = "5s" + username = "telegraf" + password = "MySt4tsBr1ngAllTheB0ys2TheYard" + # user_agent = "telegraf" + # udp_payload = 512 + + ## Optional SSL Config + # ssl_ca = "/etc/telegraf/ca.pem" + # ssl_cert = "/etc/telegraf/cert.pem" + # ssl_key = "/etc/telegraf/key.pem" + ## Use SSL but skip chain & host verification + # insecure_skip_verify = false + + # http_proxy = "http://corporate.proxy:3128" + # http_headers = {"X-Special-Header" = "Special-Value"} + # content_encoding = "gzip" + +[[inputs.cpu]] + percpu = true + totalcpu = true + collect_cpu_time = true + report_active = true + +[[inputs.disk]] + mount_points = ["/"] + ignore_fs = ["tmpfs", "devtmpfs", "devfs"] + +[[inputs.diskio]] + devices = ["sda"] + # skip_serial_number = false +[[inputs.kernel]] +[[inputs.mem]] +[[inputs.processes]] +[[inputs.swap]] +[[inputs.system]] +[[inputs.kernel_vmstat]] +[[inputs.linux_sysctl_fs]] +[[inputs.net]] +[[inputs.netstat]] + +[[inputs.exec]] + commands = [ + '/bin/cat /tmp/metadata.txt' + ] + + data_format = "influx" + +# # Collect kernel snmp counters and network interface statistics +# [[inputs.nstat]] +# ## file paths for proc files. If empty default paths will be used: +# ## /proc/net/netstat, /proc/net/snmp, /proc/net/snmp6 +# ## These can also be overridden with env variables, see README. +# proc_net_netstat = "/proc/net/netstat" +# proc_net_snmp = "/proc/net/snmp" +# proc_net_snmp6 = "/proc/net/snmp6" +# ## dump metrics with 0 values too +# dump_zeros = true + +## Emulator monitoring is below! +## Not all emulators are monitored, only ones which we're currently using +[[inputs.procstat]] + ## executable name (ie, pgrep ) + exe = "fuse64" + ## override for process_name + process_name = "Spectrum (fuse64)" + ## Add PID as a tag instead of a field; useful to differentiate between + ## processes whose tags are otherwise the same. Can create a large number + ## of series, use judiciously. + pid_tag = true + pid_finder = "pgrep" +#[[inputs.procstat]] +# ## executable name (ie, pgrep ) +# exe = "bem64" +# ## override for process_name +# process_name = "BBC Micro (bem64)" +# ## Add PID as a tag instead of a field; useful to differentiate between +# ## processes whose tags are otherwise the same. Can create a large number +# ## of series, use judiciously. +# pid_tag = true +# pid_finder = "pgrep" +#[[inputs.procstat]] +# ## executable name (ie, pgrep ) +# exe = "dosbox64" +# ## override for process_name +# process_name = "Dosbox (dosbox64)" +# ## Add PID as a tag instead of a field; useful to differentiate between +# ## processes whose tags are otherwise the same. Can create a large number +# ## of series, use judiciously. +# pid_tag = true +# pid_finder = "pgrep" +[[inputs.procstat]] + ## executable name (ie, pgrep ) + exe = "fs-uae64" + ## override for process_name + process_name = "Amiga (fs-uae64)" + ## Add PID as a tag instead of a field; useful to differentiate between + ## processes whose tags are otherwise the same. Can create a large number + ## of series, use judiciously. + pid_tag = true + pid_finder = "pgrep" +#[[inputs.procstat]] +# ## executable name (ie, pgrep ) +# exe = "mame64_136" +# ## override for process_name +# process_name = "MAME (mame64_136)" +# ## Add PID as a tag instead of a field; useful to differentiate between +# ## processes whose tags are otherwise the same. Can create a large number +# ## of series, use judiciously. +# pid_tag = true +# pid_finder = "pgrep" +[[inputs.procstat]] + ## executable name (ie, pgrep ) + exe = "mame64" + ## override for process_name + process_name = "MAME 0.184 (mame64)" + ## Add PID as a tag instead of a field; useful to differentiate between + ## processes whose tags are otherwise the same. Can create a large number + ## of series, use judiciously. + pid_tag = true + pid_finder = "pgrep" +[[inputs.procstat]] + ## executable name (ie, pgrep ) + exe = "mednafen64" + ## override for process_name + process_name = "Multi-System (mednafen64)" + ## Add PID as a tag instead of a field; useful to differentiate between + ## processes whose tags are otherwise the same. Can create a large number + ## of series, use judiciously. + pid_tag = true + pid_finder = "pgrep" +#[[inputs.procstat]] +# ## executable name (ie, pgrep ) +# exe = "openmsx64" +# ## override for process_name +# process_name = "MSX (openmsx64)" +# ## Add PID as a tag instead of a field; useful to differentiate between +# ## processes whose tags are otherwise the same. Can create a large number +# ## of series, use judiciously. +# pid_tag = true +# pid_finder = "pgrep" +#[[inputs.procstat]] +# ## executable name (ie, pgrep ) +# exe = "osmose64" +# ## override for process_name +# process_name = "SEGA Master System (osmose64)" +# ## Add PID as a tag instead of a field; useful to differentiate between +# ## processes whose tags are otherwise the same. Can create a large number +# ## of series, use judiciously. +# pid_tag = true +# pid_finder = "pgrep" +[[inputs.procstat]] + ## executable name (ie, pgrep ) + exe = "stella64" + ## override for process_name + process_name = "Atari 2600 (stella64)" + ## Add PID as a tag instead of a field; useful to differentiate between + ## processes whose tags are otherwise the same. Can create a large number + ## of series, use judiciously. + pid_tag = true + pid_finder = "pgrep" +[[inputs.procstat]] + ## executable name (ie, pgrep ) + exe = "vice64" + ## override for process_name + process_name = "Commodore (vice64)" + ## Add PID as a tag instead of a field; useful to differentiate between + ## processes whose tags are otherwise the same. Can create a large number + ## of series, use judiciously. + pid_tag = true + pid_finder = "pgrep" diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index cea36f3..2b0ba31 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -1,10 +1,8 @@ param( [switch] $Help = $false, # Allows help to be shown $azurePassword, # Azure Password - $azureUsername , # i.e: provision-serviceaccount@adminantstream.onmicrosoft.com - $azureSubscriptionName , - $azureResourceGroupName, - $vmName, + $azureUsername, # i.e: provision-serviceaccount@adminantstream.onmicrosoft.com + $azureSubscriptionName, $vmAdministratorUsername, $vmAdministratorPassword, $gameServerUsername, # CGDeploy Directory USER for demo files. Used by apache. (i.e: cginternal_tOuwMfFmBx8e1OI44SZ7) @@ -17,8 +15,7 @@ param( $emulatorShareName, # nameSSH-Sessions of the share with the emulator $environment, $region, # Region of the VM - $settingsStorageAccount, - $romStorageAccount + $settingsStorageAccount ) # Useful links # Create Linux VM https://azure.microsoft.com/en-gb/documentation/articles/virtual-machines-ps-create-preconfigure-linux-vms @@ -135,6 +132,7 @@ $libraryDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($scriptDir Import-Module "$moduleDir\azure.psm1" -Force Import-Module "$libraryDir\SSH-SessionsP\SSH-Sessions" -Force Import-Module "$moduleDir\remoting-alt.psm1" -Force #I can only apologise for this file existing +Import-Module "$moduleDir\resource-locator.psm1" -Force $scpInstalled = Get-Module -ListAvailable -Name Posh-SSH if (-Not $scpInstalled) { @@ -148,6 +146,8 @@ try { #Preparation steps $startTime = Get-Date + + $vmName = GetVmName $environment Write-Host -ForegroundColor Cyan "This deploy GameServer files to templateVM '$vmName'" Write-Host "Script started ($startTime)" DetectPowershellVersion 4 @@ -166,6 +166,8 @@ try $AzureSub = Select-AzureRmSubscription -SubscriptionName $azureSubscriptionName -Verbose Write-Host "We are now in $AzureSub.Subscription" + $azureResourceGroupName = GetAzureResourceGroupName -environment $environment -region $region + WaitVMToHaveStatus $azureResourceGroupName $vmName "VM running" 10 180 #3 Deploy @@ -189,7 +191,8 @@ try Write-Host -ForegroundColor Cyan "Step 4: Generating SAS tokens" $SettingsStorageAccount = $SettingsStorageAccount.ToLower() - $romStorageAccount = $romStorageAccount.ToLower() + $romStorageAccount = GetRomStorageAccount($environment, $region).ToLower() + Write-Host "Rom Storage Account: ${romStorageAccount}" $romSasKey = GetSasToken $romStorageAccount $romResourceGroup $romSubscription $settingsSasKey = GetSasToken $SettingsStorageAccount $settingsResourceGroup $settingsSubscription From dcb353c1717923d7c95269eb39cad7bfb8391e12 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 11 Apr 2019 17:38:44 +0100 Subject: [PATCH 23/29] feature/resource-group-param - Fixing resource storage account --- src/Build/ConfigureGSTemplate.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 2b0ba31..b92b249 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -191,7 +191,10 @@ try Write-Host -ForegroundColor Cyan "Step 4: Generating SAS tokens" $SettingsStorageAccount = $SettingsStorageAccount.ToLower() - $romStorageAccount = GetRomStorageAccount($environment, $region).ToLower() + + $romStorageAccount = GetRomStorageAccount -environment $environment -region $region + $romStorageAccount = $romStorageAccount.ToLower() + Write-Host "Rom Storage Account: ${romStorageAccount}" $romSasKey = GetSasToken $romStorageAccount $romResourceGroup $romSubscription From c8e79694738d3594b75cf6ebfd31b98c583aa31f Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 11 Apr 2019 17:53:47 +0100 Subject: [PATCH 24/29] feature/resource-group-param - Removed emulator storage and game settings storage account params --- modules/resource-locator.psm1 | 5 +++-- src/Build/ConfigureGSTemplate.ps1 | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/resource-locator.psm1 b/modules/resource-locator.psm1 index 7f7b1da..a1ec048 100644 --- a/modules/resource-locator.psm1 +++ b/modules/resource-locator.psm1 @@ -47,9 +47,10 @@ function GetDiagnosticsStorageAccountName($environment, $region) return "as${environment}rggs${region}diag01" } +# Azure storage account name for the emulators function GetEmulatorStorageAccount($environment, $region) { - return "as${environment}storage${region}" + return "as${environment}storage${region}".ToLower() } function GetGameSettingsStorageAccount() @@ -59,5 +60,5 @@ function GetGameSettingsStorageAccount() function GetRomStorageAccount($environment, $region) { - return "as${environment}storage${region}" + return "as${environment}storage${region}".ToLower() } diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index b92b249..60abe7a 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -10,12 +10,10 @@ param( $aslApiUsername, # CGDeploy ASL API Username. It will be stored in curlparams file. (i.e: ASLVMAPI) $aslApiPassword, # CGDeploy ASL API Password. It will be stored in curlparams file. $aslAddress, # ASL URL to use. It will be stored in curlparams and asladdress files. - $emulatorStorageAccount, # Azure storage account name for the emulators $emulatorAccessKey, # Key for the storage $emulatorShareName, # nameSSH-Sessions of the share with the emulator $environment, - $region, # Region of the VM - $settingsStorageAccount + $region # Region of the VM ) # Useful links # Create Linux VM https://azure.microsoft.com/en-gb/documentation/articles/virtual-machines-ps-create-preconfigure-linux-vms @@ -190,15 +188,15 @@ try Write-Host -ForegroundColor Cyan "Step 4: Generating SAS tokens" - $SettingsStorageAccount = $SettingsStorageAccount.ToLower() + $settingsStorageAccount = GetGameSettingsStorageAccount + Write-Host "Game Settings Storage Account: " + $settingsStorageAccount $romStorageAccount = GetRomStorageAccount -environment $environment -region $region - $romStorageAccount = $romStorageAccount.ToLower() Write-Host "Rom Storage Account: ${romStorageAccount}" $romSasKey = GetSasToken $romStorageAccount $romResourceGroup $romSubscription - $settingsSasKey = GetSasToken $SettingsStorageAccount $settingsResourceGroup $settingsSubscription + $settingsSasKey = GetSasToken $settingsStorageAccount $settingsResourceGroup $settingsSubscription Write-Host -ForegroundColor Cyan "Getting Eventhubs Key" $eventHubResourceGroupName = "as-$environment-rg-logs-GLOBAL" @@ -221,8 +219,10 @@ try ExecuteSSH 'sudo apt-get -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade | tee /home/antmin/cgdeploy3.log' $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false ExecuteSSH "cp -v /usr/sbin/waagent.save /usr/sbin/waagent | tee /home/antmin/cgdeploy4.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $true + $emulatorStorageAccount = GetEmulatorStorageAccount -environment $environment -region $region + Write-Host "Emulator Storage Account: ${emulatorStorageAccount}" # Run the povisioning script - $cgdeployparameters="`"$gameServerUsername`" `"$gameServerPassword`" `"$aslAddress`" `"$aslApiUsername`" `"$aslApiPassword`" `"$emulatorStorageAccount`" `"$emulatorAccessKey`" `"$emulatorShareName`" `"$region`" `"$romStorageAccount`" `"$romSasKey`" `"$SettingsStorageAccount`" `"$settingsSasKey`" `"$eventHubsKey`"" + $cgdeployparameters="`"$gameServerUsername`" `"$gameServerPassword`" `"$aslAddress`" `"$aslApiUsername`" `"$aslApiPassword`" `"$emulatorStorageAccount`" `"$emulatorAccessKey`" `"$emulatorShareName`" `"$region`" `"$romStorageAccount`" `"$romSasKey`" `"$settingsStorageAccount`" `"$settingsSasKey`" `"$eventHubsKey`"" ExecuteSSH "sudo /bin/bash /tmp/Provisioning/base.sh $cgdeployparameters 2>&1 | tee /home/antmin/cgdeploy5.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false # Switch off: sudo waagent -deprovision && sudo shutdown -h now From 64991a7eb861899bfb1aef701e9c6898e45f102f Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 12 Apr 2019 14:09:03 +0100 Subject: [PATCH 25/29] feature/resource-group-param - Re-adding reverted changes --- modules/azure.psm1 | 54 ++++++++++++++++++------------- modules/resource-locator.psm1 | 6 +++- src/Build/ConfigureGSTemplate.ps1 | 10 ++++-- 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/modules/azure.psm1 b/modules/azure.psm1 index 1bc56f3..60a60ed 100644 --- a/modules/azure.psm1 +++ b/modules/azure.psm1 @@ -1,7 +1,7 @@ #Common fuctions for Azure operations function GetSasToken($storageAccountName, $resourceGroup, $subscriptionName) -{ +{ $StartTime = Get-Date $EndTime = $startTime.AddYears(100) @@ -22,11 +22,11 @@ function GetSasToken($storageAccountName, $resourceGroup, $subscriptionName) { Write-Host "No matching sub found for $subscriptionName" VarDump($foundSubs) - Exit(1) + Exit(1) } $sub = Select-AzureRmSubscription -SubscriptionName $subscriptionName -ErrorAction Stop - + $keys = Get-AzureRmStorageAccountKey -AccountName $storageAccountName -ResourceGroupName $resourceGroup -ErrorAction Stop $key = $keys[0].Value @@ -60,18 +60,18 @@ function Remove-RmVMFull .SYNOPSIS This function is used to remove any Azure VMs as well as any attached disks. By default, this function creates a job due to the time it takes to remove an Azure VM. - + .EXAMPLE PS> Get-AzureRmVm -Name 'AS-GS111' | Remove-RmVMFull OR Remove-RmVMFull -Name $VMName -ResourceGroupName $azureResourceGroupName -Wait - + This example removes the Azure VM As-GS111 as well as any disks attached to it. - + .PARAMETER VMName The name of an Azure VM. This has an alias of Name which can be used as pipeline input from the Get-AzureRmVM cmdlet. - + .PARAMETER ResourceGroupName The name of the resource group the Azure VM is a part of. - + .PARAMETER Wait If you'd rather wait for the Azure VM to be removed before returning control to the console, use this switch parameter. If not, it will create a job and return a PSJob back. @@ -83,7 +83,7 @@ function Remove-RmVMFull [ValidateNotNullOrEmpty()] [Alias('Name')] [string]$VMName, - + [Parameter(Mandatory,ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [string]$ResourceGroupName, @@ -91,7 +91,7 @@ function Remove-RmVMFull [Parameter()] [ValidateNotNullOrEmpty()] [switch]$Wait - + ) process { try @@ -104,7 +104,7 @@ function Remove-RmVMFull 'ResourceGroupName' = $ResourceGroupName } $vm = Get-AzureRmVm @commonParams - + #region Get the VM ID $azResourceParams = @{ 'ResourceName' = $VMName @@ -114,7 +114,7 @@ function Remove-RmVMFull $vmResource = Get-AzureRmResource @azResourceParams $vmId = $vmResource.Properties.VmId #endregion - + #region Remove the boot diagnostics disk if ($vm.DiagnosticsProfile.bootDiagnostics) { @@ -132,11 +132,11 @@ function Remove-RmVMFull 'ResourceGroupName' = $diagSaRg 'Name' = $diagSa } - + Get-AzureRmStorageAccount @saParams | Get-AzureStorageContainer | where { $_.Name-eq $diagContainerName } | Remove-AzureStorageContainer -Force } #endregion - + Write-Host 'Removing the Azure VM...' $null = $vm | Remove-AzureRmVM -Force Write-Host 'Removing the Azure network interface...' @@ -150,25 +150,25 @@ function Remove-RmVMFull { Write-Host 'Removing the Public IP Address...' Remove-AzureRmPublicIpAddress -ResourceGroupName $vm.ResourceGroupName -Name $ipConfig.PublicIpAddress.Id.Split('/')[-1] -Force - } + } } - } + } + - ## Remove the OS disk Write-Host 'Removing OS disk...' $osDiskUri = $vm.StorageProfile.OSDisk.Vhd.Uri $osDiskContainerName = $osDiskUri.Split('/')[-2] - - ## TODO: Does not account for resouce group + + ## TODO: Does not account for resouce group $osDiskStorageAcct = Get-AzureRmStorageAccount | where { $_.StorageAccountName -eq $osDiskUri.Split('/')[2].Split('.')[0] } $osDiskStorageAcct | Remove-AzureStorageBlob -Container $osDiskContainerName -Blob $osDiskUri.Split('/')[-1] -ea Ignore - + #region Remove the status blob Write-Host 'Removing the OS disk status blob...' $osDiskStorageAcct | Get-AzureStorageBlob -Container $osDiskContainerName -Blob "$($vm.Name)*.status" | Remove-AzureStorageBlob #endregion - + ## Remove any other attached disks if ($vm.DataDiskNames.Count -gt 0) { @@ -180,7 +180,7 @@ function Remove-RmVMFull } } } - + if ($Wait.IsPresent) { & $scriptBlock -VMName $VMName -ResourceGroupName $ResourceGroupName @@ -193,7 +193,7 @@ function Remove-RmVMFull 'ArgumentList' = @($VMName, $ResourceGroupName) 'Name' = "Azure VM $VMName Removal" } - Start-Job @jobParams + Start-Job @jobParams } } catch @@ -238,3 +238,11 @@ function DownloadAzureStorageBlob { Write-Warning -Message ('Failed to download Azure Storage blob' -f $Blob); } } + +function GetKeyForStorageAccount { + param ([string] $resourceGroup, [string] $accountName) + + Write-Host "Getting Access Key for Storage Account: $accountName" + $accessKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroup -AccountName $accountName).Value[0]; + return $accessKey +} diff --git a/modules/resource-locator.psm1 b/modules/resource-locator.psm1 index a1ec048..01aca7a 100644 --- a/modules/resource-locator.psm1 +++ b/modules/resource-locator.psm1 @@ -35,6 +35,10 @@ function GetAzureResourceGroupName($environment, $region) { return "as-${environment}-rg-GS-${region}" } + +function GetEmulatorStorageResourceGroupName($environment, $region) { + return "as-${environment}-rg-storage-${region}" +} # Storage Accounts function GetImageStorageAccount($environment, $region) @@ -47,7 +51,7 @@ function GetDiagnosticsStorageAccountName($environment, $region) return "as${environment}rggs${region}diag01" } -# Azure storage account name for the emulators +# Azure storage account name for the emulators and roms function GetEmulatorStorageAccount($environment, $region) { return "as${environment}storage${region}".ToLower() diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 60abe7a..89940cb 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -10,7 +10,6 @@ param( $aslApiUsername, # CGDeploy ASL API Username. It will be stored in curlparams file. (i.e: ASLVMAPI) $aslApiPassword, # CGDeploy ASL API Password. It will be stored in curlparams file. $aslAddress, # ASL URL to use. It will be stored in curlparams and asladdress files. - $emulatorAccessKey, # Key for the storage $emulatorShareName, # nameSSH-Sessions of the share with the emulator $environment, $region # Region of the VM @@ -220,7 +219,14 @@ try ExecuteSSH "cp -v /usr/sbin/waagent.save /usr/sbin/waagent | tee /home/antmin/cgdeploy4.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $true $emulatorStorageAccount = GetEmulatorStorageAccount -environment $environment -region $region - Write-Host "Emulator Storage Account: ${emulatorStorageAccount}" + + Write-Host "Getting Emulator Storage Account Access Key" + $emulatorStorageResourceGroup = GetEmulatorStorageResourceGroupName -environment $environment -region $region + + Write-Host "Emulator Storage Account: ${emulatorStorageAccount}, Emulator Resource Group: ${emulatorStorageResourceGroup}" + + $emulatorAccessKey = GetKeyForStorageAccount -resourceGroup $emulatorStorageResourceGroup -accountName $emulatorStorageAccount + # Run the povisioning script $cgdeployparameters="`"$gameServerUsername`" `"$gameServerPassword`" `"$aslAddress`" `"$aslApiUsername`" `"$aslApiPassword`" `"$emulatorStorageAccount`" `"$emulatorAccessKey`" `"$emulatorShareName`" `"$region`" `"$romStorageAccount`" `"$romSasKey`" `"$settingsStorageAccount`" `"$settingsSasKey`" `"$eventHubsKey`"" ExecuteSSH "sudo /bin/bash /tmp/Provisioning/base.sh $cgdeployparameters 2>&1 | tee /home/antmin/cgdeploy5.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false From a6a69fa38a88b66c46f73a329ae51d8285d187ab Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 12 Apr 2019 14:33:23 +0100 Subject: [PATCH 26/29] feature/resource-group-param - Adding emulator share name to resource locator --- modules/resource-locator.psm1 | 5 +++++ src/Build/ConfigureGSTemplate.ps1 | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/resource-locator.psm1 b/modules/resource-locator.psm1 index 01aca7a..2ecd245 100644 --- a/modules/resource-locator.psm1 +++ b/modules/resource-locator.psm1 @@ -57,6 +57,11 @@ function GetEmulatorStorageAccount($environment, $region) return "as${environment}storage${region}".ToLower() } +function GetEmulatorFileShareName() +{ + return "binaries" +} + function GetGameSettingsStorageAccount() { return "asdevblob" diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 89940cb..81ba9ab 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -9,8 +9,7 @@ param( $gameServerPassword, # CGDeploy Directory password for demo files. Used by apache. $aslApiUsername, # CGDeploy ASL API Username. It will be stored in curlparams file. (i.e: ASLVMAPI) $aslApiPassword, # CGDeploy ASL API Password. It will be stored in curlparams file. - $aslAddress, # ASL URL to use. It will be stored in curlparams and asladdress files. - $emulatorShareName, # nameSSH-Sessions of the share with the emulator + $aslAddress, # ASL URL to use. It will be stored in curlparams and asladdress files. # nameSSH-Sessions of the share with the emulator $environment, $region # Region of the VM ) @@ -224,9 +223,10 @@ try $emulatorStorageResourceGroup = GetEmulatorStorageResourceGroupName -environment $environment -region $region Write-Host "Emulator Storage Account: ${emulatorStorageAccount}, Emulator Resource Group: ${emulatorStorageResourceGroup}" - $emulatorAccessKey = GetKeyForStorageAccount -resourceGroup $emulatorStorageResourceGroup -accountName $emulatorStorageAccount + $emulatorShareName = GetEmulatorFileShareName + Write-Host "Emultor File Share Name: ${emulatorShareName}" # Run the povisioning script $cgdeployparameters="`"$gameServerUsername`" `"$gameServerPassword`" `"$aslAddress`" `"$aslApiUsername`" `"$aslApiPassword`" `"$emulatorStorageAccount`" `"$emulatorAccessKey`" `"$emulatorShareName`" `"$region`" `"$romStorageAccount`" `"$romSasKey`" `"$settingsStorageAccount`" `"$settingsSasKey`" `"$eventHubsKey`"" ExecuteSSH "sudo /bin/bash /tmp/Provisioning/base.sh $cgdeployparameters 2>&1 | tee /home/antmin/cgdeploy5.log" $ComputerName $port $vmAdministratorUsername $vmAdministratorPassword $false From c81fcae4b453fd6c8edaa288be196318f74feaac Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 12 Apr 2019 14:38:57 +0100 Subject: [PATCH 27/29] feature/resource-group-param - Cleaned up white space --- src/Build/ConfigureGSTemplate.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 81ba9ab..586d06f 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -51,7 +51,6 @@ function dos2unix($file) $x = get-content -raw -path $file $x -replace "`r`n","`n" | set-content -path $file Write-Host "Converted." - } function WaitVMToHaveStatus($azureResourceGroupName, $vmName, $desiredStatus, $retrySeconds, [int] $maxNumberRetries) @@ -93,9 +92,9 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas while ($keepPolling) { # Function made by Steve Cottam - New-SshSession -ComputerName $ComputerName -Username $vmAdministratorUsername -Password "$vmAdministratorPassword" -Port $port -Scp -Sftp -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null + New-SshSession -ComputerName $ComputerName -Username $vmAdministratorUsername -Password "$vmAdministratorPassword" -Port $port -Scp -Sftp -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null $session = Get-SshSession -ComputerName $ComputerName - if (($session.'SSH Connected' -eq "True") -and (($session.'SCP Connected' -eq "True")) -and (($session.'SFTP Connected' -eq "True"))) + if (($session.'SSH Connected' -eq "True") -and (($session.'SCP Connected' -eq "True")) -and (($session.'SFTP Connected' -eq "True"))) { Write-Host "SSH Connected - closing this connection." Remove-SshSession -ComputerName $ComputerName @@ -103,7 +102,6 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas } else { - Write-Host "SSH Not Yet Connected. Attempt $numberRetries" } @@ -112,9 +110,8 @@ function WaitForSSH($ComputerName, $vmAdministratorUsername, $vmAdministratorPas if ($numberRetries -gt $maxNumberRetries) { - throw "Max number of retries exceeded ($numberRetries of maximum $maxNumberRetries attempts) waiting for $VM to get to state $desiredStatus" + throw "Max number of retries exceeded ($numberRetries of maximum $maxNumberRetries attempts) waiting for $VM to get to state $desiredStatus" } - } } From fa70b055dcdc5049e7a372111d7e58fe135d2206 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 12 Apr 2019 17:22:13 +0100 Subject: [PATCH 28/29] feature/resource-group-param - Removing duped telegraf.conf file --- modules/telegraf.conf | 193 ------------------------------ src/Build/ConfigureGSTemplate.ps1 | 1 - 2 files changed, 194 deletions(-) delete mode 100644 modules/telegraf.conf diff --git a/modules/telegraf.conf b/modules/telegraf.conf deleted file mode 100644 index 715475b..0000000 --- a/modules/telegraf.conf +++ /dev/null @@ -1,193 +0,0 @@ -[agent] - interval = "10s" - round_interval = true - metric_batch_size = 1000 - metric_buffer_limit = 10000 - collection_jitter = "0s" - flush_jitter = "0s" - precision = "" - debug = false - quiet = false - # Disable logging, this is stops it complaining about procstat being unable to find apps - logfile = "/dev/null" # - - hostname = "" - omit_hostname = false - -[[outputs.influxdb]] - urls = ["http://as-sql-influxdb.northeurope.cloudapp.azure.com:8086"] # required - database = "machine_stats" # required - - retention_policy = "high_stats" - write_consistency = "any" - - timeout = "5s" - username = "telegraf" - password = "MySt4tsBr1ngAllTheB0ys2TheYard" - # user_agent = "telegraf" - # udp_payload = 512 - - ## Optional SSL Config - # ssl_ca = "/etc/telegraf/ca.pem" - # ssl_cert = "/etc/telegraf/cert.pem" - # ssl_key = "/etc/telegraf/key.pem" - ## Use SSL but skip chain & host verification - # insecure_skip_verify = false - - # http_proxy = "http://corporate.proxy:3128" - # http_headers = {"X-Special-Header" = "Special-Value"} - # content_encoding = "gzip" - -[[inputs.cpu]] - percpu = true - totalcpu = true - collect_cpu_time = true - report_active = true - -[[inputs.disk]] - mount_points = ["/"] - ignore_fs = ["tmpfs", "devtmpfs", "devfs"] - -[[inputs.diskio]] - devices = ["sda"] - # skip_serial_number = false -[[inputs.kernel]] -[[inputs.mem]] -[[inputs.processes]] -[[inputs.swap]] -[[inputs.system]] -[[inputs.kernel_vmstat]] -[[inputs.linux_sysctl_fs]] -[[inputs.net]] -[[inputs.netstat]] - -[[inputs.exec]] - commands = [ - '/bin/cat /tmp/metadata.txt' - ] - - data_format = "influx" - -# # Collect kernel snmp counters and network interface statistics -# [[inputs.nstat]] -# ## file paths for proc files. If empty default paths will be used: -# ## /proc/net/netstat, /proc/net/snmp, /proc/net/snmp6 -# ## These can also be overridden with env variables, see README. -# proc_net_netstat = "/proc/net/netstat" -# proc_net_snmp = "/proc/net/snmp" -# proc_net_snmp6 = "/proc/net/snmp6" -# ## dump metrics with 0 values too -# dump_zeros = true - -## Emulator monitoring is below! -## Not all emulators are monitored, only ones which we're currently using -[[inputs.procstat]] - ## executable name (ie, pgrep ) - exe = "fuse64" - ## override for process_name - process_name = "Spectrum (fuse64)" - ## Add PID as a tag instead of a field; useful to differentiate between - ## processes whose tags are otherwise the same. Can create a large number - ## of series, use judiciously. - pid_tag = true - pid_finder = "pgrep" -#[[inputs.procstat]] -# ## executable name (ie, pgrep ) -# exe = "bem64" -# ## override for process_name -# process_name = "BBC Micro (bem64)" -# ## Add PID as a tag instead of a field; useful to differentiate between -# ## processes whose tags are otherwise the same. Can create a large number -# ## of series, use judiciously. -# pid_tag = true -# pid_finder = "pgrep" -#[[inputs.procstat]] -# ## executable name (ie, pgrep ) -# exe = "dosbox64" -# ## override for process_name -# process_name = "Dosbox (dosbox64)" -# ## Add PID as a tag instead of a field; useful to differentiate between -# ## processes whose tags are otherwise the same. Can create a large number -# ## of series, use judiciously. -# pid_tag = true -# pid_finder = "pgrep" -[[inputs.procstat]] - ## executable name (ie, pgrep ) - exe = "fs-uae64" - ## override for process_name - process_name = "Amiga (fs-uae64)" - ## Add PID as a tag instead of a field; useful to differentiate between - ## processes whose tags are otherwise the same. Can create a large number - ## of series, use judiciously. - pid_tag = true - pid_finder = "pgrep" -#[[inputs.procstat]] -# ## executable name (ie, pgrep ) -# exe = "mame64_136" -# ## override for process_name -# process_name = "MAME (mame64_136)" -# ## Add PID as a tag instead of a field; useful to differentiate between -# ## processes whose tags are otherwise the same. Can create a large number -# ## of series, use judiciously. -# pid_tag = true -# pid_finder = "pgrep" -[[inputs.procstat]] - ## executable name (ie, pgrep ) - exe = "mame64" - ## override for process_name - process_name = "MAME 0.184 (mame64)" - ## Add PID as a tag instead of a field; useful to differentiate between - ## processes whose tags are otherwise the same. Can create a large number - ## of series, use judiciously. - pid_tag = true - pid_finder = "pgrep" -[[inputs.procstat]] - ## executable name (ie, pgrep ) - exe = "mednafen64" - ## override for process_name - process_name = "Multi-System (mednafen64)" - ## Add PID as a tag instead of a field; useful to differentiate between - ## processes whose tags are otherwise the same. Can create a large number - ## of series, use judiciously. - pid_tag = true - pid_finder = "pgrep" -#[[inputs.procstat]] -# ## executable name (ie, pgrep ) -# exe = "openmsx64" -# ## override for process_name -# process_name = "MSX (openmsx64)" -# ## Add PID as a tag instead of a field; useful to differentiate between -# ## processes whose tags are otherwise the same. Can create a large number -# ## of series, use judiciously. -# pid_tag = true -# pid_finder = "pgrep" -#[[inputs.procstat]] -# ## executable name (ie, pgrep ) -# exe = "osmose64" -# ## override for process_name -# process_name = "SEGA Master System (osmose64)" -# ## Add PID as a tag instead of a field; useful to differentiate between -# ## processes whose tags are otherwise the same. Can create a large number -# ## of series, use judiciously. -# pid_tag = true -# pid_finder = "pgrep" -[[inputs.procstat]] - ## executable name (ie, pgrep ) - exe = "stella64" - ## override for process_name - process_name = "Atari 2600 (stella64)" - ## Add PID as a tag instead of a field; useful to differentiate between - ## processes whose tags are otherwise the same. Can create a large number - ## of series, use judiciously. - pid_tag = true - pid_finder = "pgrep" -[[inputs.procstat]] - ## executable name (ie, pgrep ) - exe = "vice64" - ## override for process_name - process_name = "Commodore (vice64)" - ## Add PID as a tag instead of a field; useful to differentiate between - ## processes whose tags are otherwise the same. Can create a large number - ## of series, use judiciously. - pid_tag = true - pid_finder = "pgrep" diff --git a/src/Build/ConfigureGSTemplate.ps1 b/src/Build/ConfigureGSTemplate.ps1 index 586d06f..35021d0 100644 --- a/src/Build/ConfigureGSTemplate.ps1 +++ b/src/Build/ConfigureGSTemplate.ps1 @@ -70,7 +70,6 @@ function WaitVMToHaveStatus($azureResourceGroupName, $vmName, $desiredStatus, $r } else { - Write-Host "VM Machine $vmName is not YET running. State = $vmPowerStatus. Attempt $numberRetries" } From c56960b8c0f01a27810486dc1b7e656818a5bf01 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 12 Apr 2019 17:38:14 +0100 Subject: [PATCH 29/29] feature/resouce-group-param - Formatting --- modules/resource-locator.psm1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/resource-locator.psm1 b/modules/resource-locator.psm1 index 2ecd245..929f7af 100644 --- a/modules/resource-locator.psm1 +++ b/modules/resource-locator.psm1 @@ -36,7 +36,8 @@ function GetAzureResourceGroupName($environment, $region) return "as-${environment}-rg-GS-${region}" } -function GetEmulatorStorageResourceGroupName($environment, $region) { +function GetEmulatorStorageResourceGroupName($environment, $region) +{ return "as-${environment}-rg-storage-${region}" } # Storage Accounts