Rough and ready pipeline to install NewRelic infrastructure agent on a number of VMs using AzureDevops pipeline.
If necessary, create a NewRelic account and get a licence_key
Create a repo and add the installer to it
If necessary, install Azure Agent on VMs requiring monitoring and create a deployment group for them.
Add tags to VMs in deployment group for all servers requiring monitoring
Create a pipeline
- Add a repo artifact for the repo with the MSI in it
- Add an empty job to the default stage
- Create a "deployment group" job and add tags to match tags defined above (leave blank for all VMs)
- Add a powershell task with inline script:
if(Test-Path "C:\Program Files\New Relic\newrelic-infra\newrelic-infra.exe"){
Write-Output "NewRelic infrastructure agent already installed"
} else {
Write-Output "Installing NewRelic infrastructure agent"
$msiPath = Join-Path "$(System.DefaultWorkingDirectory)" "_repo/newrelic-infra.msi"
$logPath = Join-Path "$(System.DefaultWorkingDirectory)" "_repo/newrelic-infra.log"
$args = @(
"/quiet"
"/log $logPath"
"/i $msiPath"
)
Write-Output $args
Start-Process "msiexec.exe" -ArgumentList $args -Wait -NoNewWindow
$content = Get-Content "C:\Program Files\New Relic\newrelic-infra\newrelic-infra.yml"
$content = $content -replace "<ENTER YOUR NEW RELIC KEY HERE>", "licence_key"
Set-Content -Value $content -Path "C:\Program Files\New Relic\newrelic-infra\newrelic-infra.yml"
net start newrelic-infra
}
No comments:
Post a Comment