Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Installer Script - Add support for offline installs #4471

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 42 additions & 15 deletions internal/buildscripts/packaging/installer/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@
If specified, the -collector_version and -stage parameters will be ignored.
.EXAMPLE
.\install.ps1 -access_token "ACCESSTOKEN" -msi_path "C:\SOME_FOLDER\splunk-otel-collector-1.2.3-amd64.msi"
.PARAMETER dotnet_psm1_path
(OPTIONAL) Specify a local path to a Splunk OpenTelemetry .NET Auto Instrumentation Powershell Module file (.psm1) instead of downloading the package. This module will be used to install the .NET auto instrumentation files. The most current PSM1 file can be downloaded at https://github.com/signalfx/splunk-otel-dotnet/releases
.EXAMPLE
.\install.ps1 -access_token "ACCESSTOKEN" -dotnet_psm1_path "C:\SOME_FOLDER\Splunk.OTel.DotNet.psm1"
.PARAMETER dotnet_auto_zip_path
(OPTIONAL) Specify a local path to a Splunk OpenTelemetry .NET Auto Instrumentation zip package that will be installed by the dotnet psm1 module instead of downloading the package. The most current zip file can be downloaded at https://github.com/signalfx/splunk-otel-dotnet/releases
.EXAMPLE
.\install.ps1 -access_token "ACCESSTOKEN" -dotnet_auto_zip_path "C:\SOME_FOLDER\splunk-otel-dotnet-1.2.3-amd64.zip"
.PARAMETER force_skip_verify_access_token
(OPTIONAL) Forces the skipping the verification check of the Splunk Observability Access Token regardless of what is in the env variable VERIFY_ACCESS_TOKEN. This is helpful on new installs where access might be an issue or the token isn't created yet.
.EXAMPLE
.\install.ps1 -access_token "ACCESSTOKEN" -force_skip_verify_access_token $true
.PARAMETER msi_public_properties
(OPTIONAL) Specify public MSI properties to be used when installing the Splunk OpenTelemetry Collector MSI package.
For information about the public MSI properties see https://learn.microsoft.com/en-us/windows/win32/msi/property-reference#configuration-properties
Expand Down Expand Up @@ -140,6 +152,9 @@ param (
[string]$config_path = "",
[string]$collector_msi_url = "",
[string]$fluentd_msi_url = "",
[string]$dotnet_psm1_path = "",
[string]$dotnet_auto_zip_path = "",
[bool]$force_skip_verify_access_token = $false,
[string]$deployment_env = "",
[bool]$UNIT_TEST = $false
)
Expand Down Expand Up @@ -495,12 +510,19 @@ if ($with_dotnet_instrumentation) {
throw "SignalFx .NET Instrumentation is already installed. Stop all instrumented applications and uninstall SignalFx Instrumentation for .NET before running this script again."
}
echo "Downloading Splunk Distribution of OpenTelemetry .NET ..."
$module_name = "Splunk.OTel.DotNet.psm1"
$download = "https://github.com/signalfx/splunk-otel-dotnet/releases/latest/download/$module_name"
$dotnet_autoinstr_path = Join-Path $tempdir $module_name
echo "Downloading .NET Instrumentation installer ..."
Invoke-WebRequest -Uri $download -OutFile $dotnet_autoinstr_path -UseBasicParsing
Import-Module $dotnet_autoinstr_path
if ($dotnet_psm1_path -eq "") {
$module_name = "Splunk.OTel.DotNet.psm1"
$download = "https://github.com/signalfx/splunk-otel-dotnet/releases/latest/download/$module_name"
$dotnet_autoinstr_path = Join-Path $tempdir $module_name
echo "Downloading .NET Instrumentation installer ..."
Invoke-WebRequest -Uri $download -OutFile $dotnet_autoinstr_path -UseBasicParsing
Import-Module $dotnet_autoinstr_path
} else {
$dotnet_autoinstr_path = $dotnet_psm1_path
echo "Using Local PSM1 file and ArgumentList values: $dotnet_psm1_path -ArgumentList $dotnet_auto_zip_path"
Import-Module $dotnet_autoinstr_path -ArgumentList $dotnet_auto_zip_path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think -ArgumentList is needed here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it with the -ArgumentList and the values were successfully passed to the PSM1 file. I didn't try without it. I found this method of passing arguments in this StackOverflow article.
https://stackoverflow.com/questions/36897511/powershell-module-pass-a-parameter-while-importing-module

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter in this case because the module doesn't have module level parameters.

}

}

if ($ingest_url -eq "") {
Expand All @@ -527,14 +549,18 @@ if ($bundle_dir -eq "") {
$bundle_dir = "$installation_path\agent-bundle"
}

if ("$env:VERIFY_ACCESS_TOKEN" -ne "false") {
# verify access token
echo 'Verifying Access Token...'
if (!(verify_access_token -access_token $access_token -ingest_url $ingest_url -insecure $insecure)) {
throw "Access token authentication failed. Verify that your access token is correct."
}
else {
echo '- Verified Access Token'
if ($force_skip_verify_access_token) {
echo 'Skipping Access Token verification'
} else {
if ("$env:VERIFY_ACCESS_TOKEN" -ne "false") {
# verify access token
echo 'Verifying Access Token...'
if (!(verify_access_token -access_token $access_token -ingest_url $ingest_url -insecure $insecure)) {
throw "Access token authentication failed. Verify that your access token is correct."
}
else {
echo '- Verified Access Token'
}
}
}

Expand Down Expand Up @@ -704,7 +730,8 @@ if ($with_dotnet_instrumentation) {
throw "The Splunk Distribution of OpenTelemetry .NET is already installed. Stop all instrumented applications and uninstall it and then rerun this script."
}

Install-OpenTelemetryCore
# If the variable dotnet_auto_zip_path is an empty string, then the Installer will download the .NET Instrumentation from the default repository.
Install-OpenTelemetryCore -LocalPath $dotnet_auto_zip_path
pjanotti marked this conversation as resolved.
Show resolved Hide resolved

$installed_version = Get-OpenTelemetryInstallVersion
if ($otel_resource_attributes -ne "") {
Expand Down
Loading