-
Notifications
You must be signed in to change notification settings - Fork 19
/
grafana-setup.yml
125 lines (114 loc) · 4.61 KB
/
grafana-setup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
trigger:
branches:
exclude:
- '*'
variables:
# Cannot use key:value syntax in root defined variables
- name: _TeamName
value: DotNetCore
- name: _PublishUsingPipelines
value: true
- name: _DotNetArtifactsCategory
value: .NETCore
# This can be overridden if we are using a locally built fork
- group: Dotnet Grafana
# Variables we want to be settable, so can't be defined here:
# GrafanaBinPath: /usr/sbin/grafana-server
# TargetVmName: grafana
# TargetResourceGroup: monitoring
stages:
- stage: SynchronizeSecrets
jobs:
- job: Synchronize
pool:
name: NetCore1ESPool-Internal-NoMSI
demands: ImageOverride -equals 1es-windows-2019
steps:
- task: UseDotNet@2
displayName: Install Correct .NET Version
inputs:
useGlobalJson: true
- task: UseDotNet@2
displayName: Install .NET 3.1 runtime
inputs:
packageType: runtime
version: 3.1.x
- script: dotnet build
displayName: Build SecretManager
workingDirectory: src/SecretManager/Microsoft.DncEng.SecretManager
- task: AzureCLI@2
displayName: Synchronize Grafana secrets
inputs:
azureSubscription: DotNet Eng Services Secret Manager
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
dotnet run --project src/SecretManager/Microsoft.DncEng.SecretManager -- synchronize .vault-config/dotnet-grafana-staging.yaml
- stage: deploy
displayName: Deploy grafana server
jobs:
- template: /eng/common/templates/jobs/jobs.yml
parameters:
enableMicrobuild: false
enablePublishBuildArtifacts: false
enablePublishTestResults: false
enablePublishBuildAssets: false
enablePublishUsingPipelines: ${{ variables._PublishUsingPipelines }}
enableTelemetry: false
helixRepo: dotnet/dnceng
jobs:
- job: Windows_NT
timeoutInMinutes: 90
pool:
name: NetCore1ESPool-Internal-NoMSI
demands: ImageOverride -equals 1es-windows-2019
steps:
- checkout: self
clean: true
- powershell: |
if (-not (Test-Path env:GrafanaDomain)) { Write-Host "Missing GrafanaDomain, ensure required variables are defined"; exit 1}
if (-not (Test-Path env:TargetVmName)) { Write-Host "Missing TargetVmName, ensure required variables are defined"; exit 1}
if (-not (Test-Path env:TargetResourceGroup)) { Write-Host "Missing TargetResourceGroup, ensure required variables are defined"; exit 1}
if ($env:GrafanaEnvironment -ne "staging" -and $env:GrafanaEnvironment -ne "production") { Write-Host "GrafanaEnvironment must be 'staging' or 'production'"; exit 1}
Write-Host "All required variables defined"
displayName: Ensure variables defined
- task: ArchiveFiles@2
displayName: Create grafana-init archive
inputs:
rootFolderOrFile: $(Build.SourcesDirectory)\src\Monitoring\grafana-init
includeRootFolder: false
archiveType: tar
tarCompression: gz
archiveFile: $(Build.ArtifactStagingDirectory)/grafana-init.tar.gz
- task: AzureFileCopy@3
displayName: Copy grafana-init to VM
inputs:
sourcePath: $(Build.ArtifactStagingDirectory)/grafana-init.tar.gz
azureSubscription: DncEng-VSTS
storage: dotnetgrafana
containerName: build-transfer
blobPrefix: grafana-init-$(Build.BuildNumber)
destination: azureBlob
outputStorageUri: UploadedUri
- task: AzureCLI@2
displayName: Execute grafana-init/setup.sh on VM
inputs:
azureSubscription: DncEng-VSTS
scriptType: pscore
scriptLocation: inlineScript
inlineScript: >-
az vm run-command invoke
-g $(TargetResourceGroup)
-n $(TargetVmName)
--command-id RunShellScript
--scripts
"
mkdir -p /tmp/grafana-init/ &&
cd /tmp/grafana-init &&
curl --silent --show-error --fail '$(UploadedUri)grafana-init-$(Build.BuildNumber)/grafana-init.tar.gz' -o ./grafana-init.tar.gz &&
tar -xzf ./grafana-init.tar.gz &&
sudo bash ./setup.sh -b '$(GrafanaBinPath)' -d '$(GrafanaDomain)' --$(GrafanaEnvironment)
"
| Tee-Object -variable cmdoutput
|% {$_ -replace "\\n","`n-> "} |% {$_ -replace "\\",""} | Write-Host;
select-string -inputObject $cmdoutput -pattern "SETUP_EXIT_CODE=0" -quiet -simpleMatch || exit 1