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

Set env vars for service instead of machine #3930

Merged
merged 78 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
e6a4634
Set env vars for service instead of machine
pjanotti Nov 17, 2023
8dd68c7
Fix copy and pasted typo
pjanotti Nov 17, 2023
810e4f0
Remove unused variable
pjanotti Nov 17, 2023
e5858d6
Update chocolatey to use env vars at the service scope
pjanotti Nov 17, 2023
d50a9c5
Fix check for "SPLUNK_ACCESS_TOKEN"
pjanotti Nov 17, 2023
640e405
Handle upgrade in chocolatey
pjanotti Nov 17, 2023
50a8cb5
Get-Package not available on all Windows versions
pjanotti Nov 18, 2023
aecc559
Add messages to track stage on chocolatey install
pjanotti Nov 18, 2023
bf7f0a4
Adding more messages to chocolatey script
pjanotti Nov 18, 2023
da12a5b
Fix service on the registry but no env
pjanotti Nov 18, 2023
fe6a0ce
Restore $regKey on install.ps1
pjanotti Nov 18, 2023
e091ad7
Add helper allow running the collector manually on Windows
pjanotti Nov 27, 2023
5282d07
Add breaking change to CHANGELOG.md
pjanotti Nov 27, 2023
43f49f1
Add -config_path switch to install.ps1
pjanotti Dec 1, 2023
224ab0b
Fix pipeline collector for Windows ZC IIS test
pjanotti Dec 1, 2023
51ed501
MSI to set SPLUNK_CONFIG at the service scope
pjanotti Dec 4, 2023
9a5310a
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 4, 2023
75638da
Minor doc updates
pjanotti Dec 6, 2023
a82a0bf
Update ansible tests for Windows env vars
pjanotti Dec 7, 2023
bb0cce6
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 7, 2023
802a505
Correct type of *_ENABLE_PROFILING value
pjanotti Dec 8, 2023
32e46d1
Merge branch 'move-windows-env-vars-to-service' of github.com:pjanott…
pjanotti Dec 8, 2023
96b256a
ansible: Windows deployment updates
pjanotti Dec 8, 2023
35c6573
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 8, 2023
5b7ab83
fix yamllint issues
pjanotti Dec 8, 2023
3c5c1ab
Merge branch 'move-windows-env-vars-to-service' of github.com:pjanott…
pjanotti Dec 8, 2023
831c6d0
fix yamllint
pjanotti Dec 8, 2023
d3435b8
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 11, 2023
1ca8eac
Output vagrant.err in case of failure
pjanotti Dec 11, 2023
f51de23
Fix splunk_trace_url check
pjanotti Dec 11, 2023
21944bb
Always try to display the vagrant errors
pjanotti Dec 11, 2023
0d543e5
Check if event log has some info about failure
pjanotti Dec 12, 2023
d51b65a
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 12, 2023
c399f39
Remove event log steps: running on mac not Windows
pjanotti Dec 12, 2023
c61b1a7
Launch vagrant
pjanotti Dec 13, 2023
82b7846
Init vagrant
pjanotti Dec 13, 2023
44c04f0
Drop launch vagrant step
pjanotti Dec 13, 2023
ffcb73e
Fix ansible Windows
pjanotti Dec 16, 2023
8c8e1bb
Fix yamllint issues
pjanotti Dec 16, 2023
e34afce
Remove vagrant init
pjanotti Jan 2, 2024
9c77ee1
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Jan 2, 2024
237bc45
Updates to pass local run of molecule tests
pjanotti Jan 4, 2024
94602d8
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Jan 10, 2024
3658946
Update chef deployment
pjanotti Jan 10, 2024
0719a1e
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Jan 10, 2024
bf9d767
Proper data type for multi_string registry entry
pjanotti Jan 10, 2024
3c50447
Fix var name typo
pjanotti Jan 10, 2024
d00b8e6
Fix order of collector environment variables
pjanotti Jan 11, 2024
6388b90
Experiment custom_vars test
pjanotti Jan 11, 2024
4ff26c6
Pay attention to conditional variables
pjanotti Jan 11, 2024
069ee45
First try with Puppet
pjanotti Jan 12, 2024
cbaf5d4
Fix syntax for Puppet
pjanotti Jan 13, 2024
1578caa
Back to curly brackets
pjanotti Jan 13, 2024
4f18580
Try extension fixes
pjanotti Jan 13, 2024
50f9c0f
Fix conditional
pjanotti Jan 13, 2024
782aae0
Remove to_s
pjanotti Jan 13, 2024
4d8465e
Use empty instead of is_empty
pjanotti Jan 13, 2024
6bbc178
Fix re-declaration of registry_key
pjanotti Jan 13, 2024
b7dcb09
Fix puppet lint issue
pjanotti Jan 13, 2024
2c3af09
Do not re-use registry_key
pjanotti Jan 13, 2024
e87063b
Use array instead of multi_string
pjanotti Jan 13, 2024
e1cf478
Ensure side effects
pjanotti Jan 13, 2024
2f6ecf4
Update test to use REG_MULTI_SZ
pjanotti Jan 13, 2024
d193f50
Immutability?
pjanotti Jan 13, 2024
faca2ce
Fix lint error
pjanotti Jan 13, 2024
e1ca7c3
Fix test
pjanotti Jan 13, 2024
52a6ebf
Removing name re-use
pjanotti Jan 13, 2024
1b1007f
Update CHANGELOG and README for Puppet
pjanotti Jan 13, 2024
5edf011
Updates to mass deployments docs
pjanotti Jan 13, 2024
eb38784
Update last version deploying with machine wide env vars
pjanotti Jan 16, 2024
b140644
Sort service environment variables set via PowerShell
pjanotti Jan 16, 2024
34925c2
Improve handling of collector restart in Ansible
pjanotti Jan 16, 2024
b8b7005
Remove extra double-quotes in SPLUNK_CONFIG for Ansible
pjanotti Jan 16, 2024
8287246
Fix Ansible verify SPLUNK_CONFIG strings
pjanotti Jan 17, 2024
7b076c6
Fix Windows testing checking for legacy versions of the collector
pjanotti Jan 17, 2024
bc206a2
Update CHANGELOG.md
pjanotti Jan 19, 2024
3ca07b7
Update last version still setting machine wide env vars
pjanotti Jan 19, 2024
33534ea
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 16 additions & 10 deletions internal/buildscripts/packaging/installer/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
For information about the public MSI properties see https://learn.microsoft.com/en-us/windows/win32/msi/property-reference#configuration-properties
.EXAMPLE
.\install.ps1 -access_token "ACCESSTOKEN" -msi_public_properties "ALLUSERS=1"
.PARAMETER config_path
(OPTIONAL) Specify a local path to an alternative configuration file for the Splunk OpenTelemetry Collector.
If specified, the -mode parameter will be ignored.
.EXAMPLE
.\install.ps1 -config_path "C:\SOME_FOLDER\my_config.yaml"
#>

param (
Expand All @@ -132,6 +137,7 @@ param (
[ValidateSet('test','beta','release')][string]$stage = "release",
[string]$msi_path = "",
[string]$msi_public_properties = "",
[string]$config_path = "",
[string]$collector_msi_url = "",
[string]$fluentd_msi_url = "",
[string]$deployment_env = "",
Expand All @@ -157,7 +163,6 @@ try {
$old_config_path = "$program_data_path\config.yaml"
$agent_config_path = "$program_data_path\agent_config.yaml"
$gateway_config_path = "$program_data_path\gateway_config.yaml"
$config_path = ""

try {
Resolve-Path $env:TEMP 2>&1>$null
Expand Down Expand Up @@ -578,20 +583,20 @@ if (!(Test-Path -Path "$old_config_path") -And (Test-Path -Path "$installation_p
Copy-Item "$installation_path\config.yaml" "$old_config_path"
}

if (($mode -Eq "agent") -And (Test-Path -Path "$agent_config_path")) {
$config_path = $agent_config_path
} elseif (($mode -Eq "gateway") -And (Test-Path -Path "$gateway_config_path")) {
$config_path = $gateway_config_path
}

if ($config_path -Eq "") {
if (Test-Path -Path "$old_config_path") {
if (($mode -Eq "agent") -And (Test-Path -Path "$agent_config_path")) {
$config_path = $agent_config_path
} elseif (($mode -Eq "gateway") -And (Test-Path -Path "$gateway_config_path")) {
$config_path = $gateway_config_path
} elseif (Test-Path -Path "$old_config_path") {
$config_path = $old_config_path
} else {
throw "Valid Collector configuration file not found."
}
}

if (!(Test-Path -Path "$config_path")) {
throw "Valid Collector configuration file not found at $config_path."
}

$collector_env_vars = @{
"SPLUNK_ACCESS_TOKEN" = "$access_token";
"SPLUNK_API_URL" = "$api_url";
Expand All @@ -604,6 +609,7 @@ $collector_env_vars = @{
"SPLUNK_REALM" = "$realm";
"SPLUNK_TRACE_URL" = "$trace_url";
}

if ($network_interface -Ne "") {
$collector_env_vars.Add("SPLUNK_LISTEN_INTERFACE", "$network_interface")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\EventLog\Application\splunk-otel-collector">
<RegistryValue Type="expandable" Name="EventMessageFile" Value="%SystemRoot%\System32\EventCreate.exe"/>
</RegistryKey>
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment">
<RegistryValue Type="string" Name="SPLUNK_CONFIG" Value="[CommonAppDataFolder]Splunk\OpenTelemetry Collector\agent_config.yaml"/>
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\splunk-otel-collector">
rmfitzpatrick marked this conversation as resolved.
Show resolved Hide resolved
<RegistryValue Type="multiString" Name="Environment">
<MultiStringValue>SPLUNK_CONFIG=[CommonAppDataFolder]Splunk\OpenTelemetry Collector\agent_config.yaml"</MultiStringValue>
</RegistryValue>
</RegistryKey>
</Component>
</Directory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ ENV ACCESS_TOKEN_TMP=$access_token
RUN `
$token = $Env:ACCESS_TOKEN_TMP; `
$collector_msi_path = (dir "c:\setup\splunk-otel-collector-*.msi").FullName; `
c:\setup\install.ps1 -access_token $token -msi_path $collector_msi_path -with_fluentd $false -ingest_url "http://192.0.2.1:12345" -trace_url "http://192.0.2.1:12345" -network_interface "0.0.0.0"
c:\setup\install.ps1 -access_token $token -msi_path $collector_msi_path -config_path "C:\setup\pipeline-collector.yaml" -with_fluentd $false -ingest_url "http://192.0.2.1:12345" -trace_url "http://192.0.2.1:12345" -network_interface "0.0.0.0"
ENV ACCESS_TOKEN_TMP=
RUN `
Set-ItemProperty -force -path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -name 'SPLUNK_CONFIG' -value 'C:\setup\pipeline-collector.yaml'

# On docker compose the entry point needs to be changed to something that keeps the container alive.
ENTRYPOINT [ "powershell", "-Command", "Start-Sleep 1; While ($? -eq '1') { Start-Sleep 1; Invoke-WebRequest -Uri http://localhost:13133/health_check -TimeoutSec 5 -UseBasicParsing }" ]
ENTRYPOINT [ "powershell", "-Command", "Start-Sleep 5; While ($? -eq '1') { Start-Sleep 5; Invoke-WebRequest -Uri http://localhost:13133/health_check -TimeoutSec 10 -UseBasicParsing }" ]