Last active
July 17, 2023 18:30
-
-
Save andrewmatveychuk/f9eb8444ea28d405adbc386677258d84 to your computer and use it in GitHub Desktop.
Sample DSC configuration for enrolling a server for monitoring with Datadog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration datadogConfiguration { | |
#Importing required DSC resources | |
Import-DscResource -ModuleName PSDesiredStateConfiguration | |
Import-DscResource -ModuleName xPSDesiredStateConfiguration | |
#Getting the configuration parameters for deployment | |
$datadogAPIKey = Get-AutomationVariable -Name "datadogAPIKey" | |
$datadogSite = Get-AutomationVariable -Name "datadogSite" | |
#Download location for Datadog Monitoring agent package | |
$datadogAgentPackageLocalPath = "C:\Deploy\datadog-agent-7-latest.amd64.msi" | |
Node localhost { | |
#region Datadog Monitoring agent | |
#Download installation file for Datadog Monitoring agent | |
xRemoteFile datadogAgentPackage { | |
Uri = "https://s3.amazonaws.com/ddagent-windows-stable/datadog-agent-7-latest.amd64.msi" | |
DestinationPath = $datadogAgentPackageLocalPath | |
} | |
#Installing Datadog Monitoring agent on a host | |
xPackage datadogAgent { | |
Name = "Datadog Agent" | |
Ensure = "Present" | |
Path = $datadogAgentPackageLocalPath | |
Arguments = "APIKEY=" + $datadogAPIKey + " SITE=" + $datadogSite | |
ProductId = "6AFE2B52-EB1F-4D0D-8C22-E1003ADA1196" | |
DependsOn = "[xRemoteFile]datadogAgentPackage" | |
} | |
#Verifying that the agent service is running | |
xService datadogAgentService { | |
Name = "datadogagent" | |
Ensure = "Present" | |
State = "Running" | |
DependsOn = "[xPackage]datadogAgent" | |
} | |
#Logging the installation in the event log (Microsoft-Windows-Desired State Configuration/Analytic event log) | |
Log datadogAgentInstalled { | |
Message = "Datadog Monitoring Agent has been successfully installed." | |
DependsOn = "[xPackage]datadogAgent" | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing this. Very nice! Will save me some work for sure.