Skip to content

Commit

Permalink
add example datadog agent recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
jgstew committed Feb 2, 2024
1 parent e7761a8 commit 082d94a
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
56 changes: 56 additions & 0 deletions DataDog/DataDogAgent-Win-Install_Update.bes.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
<{{TypeTaskOrFixlet}}{{^TypeTaskOrFixlet}}Task{{/TypeTaskOrFixlet}}>
<Title>{{^patch}}Install/{{/patch}}Update: {{DisplayName}} v{{version}} - Windows{{#64BitOnly}} (x64){{/64BitOnly}}</Title>
<Description><![CDATA[
This task will download and install "{{DisplayName}} v{{version}}" package onto selected endpoints <br><br><b>Run Command As:</b> System User<br><br><b>Download Size:</b> {{DownloadSize}}
{{^patch}}{{#icon_base64}}<br/><br/><b>Icon:</b><br/><img style="display:block; width:256px;" src="data:{{icon_type}}{{^icon_type}}image/png{{/icon_type}};base64,{{icon_base64}}" />{{/icon_base64}}{{/patch}}
]]></Description>
<Relevance>windows of operating system</Relevance>
{{#64BitOnly}}
<Relevance><![CDATA[x64 of operating system]]></Relevance>
{{/64BitOnly}}
<Relevance><![CDATA[ not exists login accounts whose(it does not end with "\ddagentuser") of services "datadogagent" ]]></Relevance>
{{#patch}}{{#DisplayName}}
<Relevance><![CDATA[ exists keys whose(value "DisplayName" of it as string starts with "{{DisplayName}}") of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries) ]]></Relevance>
{{/DisplayName}}{{/patch}}
<Relevance><![CDATA[
not exists (it as string as version) whose(it >= "{{version}}") of values "DisplayVersion" of keys whose(value "DisplayName" of it as string starts with "{{DisplayName}}") of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)
]]></Relevance>
<Category></Category>
<DownloadSize>{{DownloadSize}}{{^DownloadSize}}0{{/DownloadSize}}</DownloadSize>
<Source>{{DisplayName}}</Source>
<SourceID></SourceID>
<SourceReleaseDate>{{SourceReleaseDate}}</SourceReleaseDate>
<SourceSeverity></SourceSeverity>
<CVENames></CVENames>
<SANSID></SANSID>
<MIMEField>
<Name>action-ui-metadata</Name>
<Value>{ {{#version}}"version":"{{version}}",{{/version}}"size":{{DownloadSize}}{{^DownloadSize}}0{{/DownloadSize}}{{^patch}}{{#icon_base64}},"icon":"data:{{icon_type}}{{^icon_type}}image/png{{/icon_type}};base64,{{icon_base64}}"{{/icon_base64}}{{/patch}} }</Value>
</MIMEField>
<MIMEField>
<Name>x-fixlet-modification-time</Name>
<Value>{{x-fixlet-modification-time}}</Value>
</MIMEField>
<Domain>BESC</Domain>
<DefaultAction ID="Action1">
<Description>
<PreLink>Click </PreLink>
<Link>here</Link>
<PostLink> to deploy {{DisplayName}} v{{version}}.</PostLink>
</Description>
<ActionScript MIMEType="application/x-Fixlet-Windows-Shell"><![CDATA[
// Download:
{{{prefetch}}}
// Install:
override wait
hidden=true
completion=job
wait msiexec.exe /i __Download\{{{file_name}}} /qn /norestart
]]></ActionScript>
<SuccessCriteria Option="OriginalRelevance"></SuccessCriteria>
</DefaultAction>
</{{TypeTaskOrFixlet}}{{^TypeTaskOrFixlet}}Task{{/TypeTaskOrFixlet}}>
</BES>
38 changes: 38 additions & 0 deletions DataDog/DataDogAgent-Win.bigfix.recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
Description: Generates a BigFix Task for the latest DataDog Agent
Identifier: com.github.jgstew.bigfix.DataDog-Win
Input:
NAME: DataDogAgent-Win
DisplayName: Datadog Agent
64BitOnly: TRUE
MinimumVersion: "2.3"
ParentRecipe: com.github.jgstew.download.DataDog-Agent-Win
Process:
- Processor: com.github.jgstew.SharedProcessors/BigFixPrefetchItem

- Processor: com.github.jgstew.SharedProcessors/BigFixSetupTemplateDictionary
# Arguments:
# template_version: "%version_maximum%"

- Processor: com.github.jgstew.SharedProcessors/TemplateDictionaryAppendInput

- Processor: com.github.jgstew.SharedProcessors/ContentFromTemplate
Arguments:
# use UNIX style paths so this works on Windows and non-Windows:
template_file_path: ./DataDog/DataDogAgent-Win-Install_Update.bes.mustache
content_file_pathname: "%RECIPE_CACHE_DIR%/%NAME%-InstallUpdate.bes"

- Processor: com.github.jgstew.SharedProcessors/BESImport

- Processor: com.github.jgstew.SharedProcessors/BigFixActioner

# create update(patch) only content:
- Processor: com.github.jgstew.SharedProcessors/TemplateDictionaryAppend
Arguments:
append_key: "patch"
append_value: true

- Processor: com.github.jgstew.SharedProcessors/ContentFromTemplate
Arguments:
# template_file_path: "./%VendorFolder%/%NAME%-Win-Install_Update.bes.mustache"
content_file_pathname: "%RECIPE_CACHE_DIR%/%NAME%-Update.bes"
38 changes: 38 additions & 0 deletions DataDog/DataDogAgent-Win.download.recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
Description: Downloads the latest DataDog Agent for Windows
Identifier: com.github.jgstew.download.DataDog-Agent-Win
Input:
NAME: DataDog-Agent-Win
DisplayName: Datadog Agent
MinimumVersion: "2.3"
Process:
# get all versions found in this JSON doc:
- Processor: com.github.jgstew.SharedProcessors/URLTextSearcherArray
Arguments:
url: https://ddagent-windows-stable.s3.amazonaws.com/installers_v2.json
re_pattern: '(\d+\.\d+\.\d+)-'

# get the maximum version:
- Processor: com.github.jgstew.SharedProcessors/VersionMaximumArray

- Processor: URLDownloaderPython
Arguments:
# %version_maximum%
url: https://s3.amazonaws.com/ddagent-windows-stable/ddagent-cli-%version_maximum%.msi
filename: datadog-agent-x86_64.msi
download_version: ""
COMPUTE_HASHES: True

- Processor: EndOfCheckPhase

# Get apparent SourceReleaseDate from MSI metadata:
- Processor: com.github.jgstew.SharedProcessors/FileMsiGetInfoOLE

# Get version number from MSI ProductVersion:
- Processor: com.github.jgstew.SharedProcessors/FileMsiGetProperty

# verify version is set correctly, at least major.minor:
- Processor: com.github.jgstew.SharedProcessors/TextSearcher
Arguments:
input_string: "%version%"
re_pattern: '^\d+\.\d+'

0 comments on commit 082d94a

Please sign in to comment.