diff --git a/README.md b/README.md index f47ef52369..815e4752a5 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ listen to configure the `SPLUNK_DEBUG_CONFIG_SERVER_PORT` environment variable. You can use the environment variable `SPLUNK_LISTEN_INTERFACE` and associated installer option to configure the network interface on which the collector's receivers and telemetry endpoints will listen. -The default value of `SPLUNK_LISTEN_INTERFACE` is set to `0.0.0.0`. +The default value of `SPLUNK_LISTEN_INTERFACE` is set to `127.0.0.1` for the default agent configuration and `0.0.0.0` otherwise. ## Upgrade guidelines diff --git a/deployments/ansible/CHANGELOG.md b/deployments/ansible/CHANGELOG.md index 4bcdb5eb99..efd315331d 100644 --- a/deployments/ansible/CHANGELOG.md +++ b/deployments/ansible/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## unrelease + +### 💡 Enhancements 💡 + +- Only propagate `splunk_listen_interface` to target SPLUNK_LISTEN_INTERFACE service environment variable if set. + ## ansible-v0.22.0 ### 💡 Enhancements 💡 diff --git a/deployments/ansible/molecule/custom_vars/converge.yml b/deployments/ansible/molecule/custom_vars/converge.yml index cf0ba3d6d6..986608dc47 100644 --- a/deployments/ansible/molecule/custom_vars/converge.yml +++ b/deployments/ansible/molecule/custom_vars/converge.yml @@ -13,7 +13,7 @@ splunk_service_group: custom-group splunk_memory_total_mib: 256 splunk_ballast_size_mib: 100 - splunk_listen_interface: 127.0.0.1 + splunk_listen_interface: 1.2.3.4 splunk_fluentd_config: /etc/otel/collector/fluentd/custom_fluentd.conf splunk_fluentd_config_source: ./custom_fluentd_config.conf install_fluentd: yes diff --git a/deployments/ansible/molecule/custom_vars/verify.yml b/deployments/ansible/molecule/custom_vars/verify.yml index 0e3d93ffab..d634b808cd 100644 --- a/deployments/ansible/molecule/custom_vars/verify.yml +++ b/deployments/ansible/molecule/custom_vars/verify.yml @@ -95,7 +95,7 @@ - name: Assert SPLUNK_LISTEN_INTERFACE env var is set ansible.builtin.lineinfile: - line: SPLUNK_LISTEN_INTERFACE=127.0.0.1 + line: SPLUNK_LISTEN_INTERFACE=1.2.3.4 dest: /etc/otel/collector/splunk-otel-collector.conf state: present check_mode: yes diff --git a/deployments/ansible/molecule/custom_vars/windows-converge.yml b/deployments/ansible/molecule/custom_vars/windows-converge.yml index 1b23158d45..df39cdd34d 100644 --- a/deployments/ansible/molecule/custom_vars/windows-converge.yml +++ b/deployments/ansible/molecule/custom_vars/windows-converge.yml @@ -14,7 +14,7 @@ splunk_memory_total_mib: 256 splunk_ballast_size_mib: 100 install_fluentd: yes - splunk_listen_interface: 127.0.0.1 + splunk_listen_interface: 1.2.3.4 splunk_fluentd_config: '{{ansible_env.ProgramFiles}}\Splunk\OpenTelemetry Collector\fluentd\custom_config.conf' splunk_fluentd_config_source: ./custom_fluentd_config.conf splunk_otel_collector_additional_env_vars: diff --git a/deployments/ansible/roles/collector/defaults/main.yml b/deployments/ansible/roles/collector/defaults/main.yml index 63a76e3e0b..74832d8eef 100644 --- a/deployments/ansible/roles/collector/defaults/main.yml +++ b/deployments/ansible/roles/collector/defaults/main.yml @@ -31,7 +31,7 @@ splunk_memory_total_mib: 512 # 1/3 of memory_mib by default splunk_ballast_size_mib: "" -splunk_listen_interface: "0.0.0.0" +splunk_listen_interface: "" install_fluentd: false # Whether to start the services installed by the role (splunk-otel-collector and td-agent). start_service: true diff --git a/deployments/ansible/roles/collector/tasks/otel_win_reg.yml b/deployments/ansible/roles/collector/tasks/otel_win_reg.yml index 1d78ad0e99..ebf2f8b3ec 100644 --- a/deployments/ansible/roles/collector/tasks/otel_win_reg.yml +++ b/deployments/ansible/roles/collector/tasks/otel_win_reg.yml @@ -76,6 +76,7 @@ name: SPLUNK_LISTEN_INTERFACE data: "{{splunk_listen_interface}}" type: string + when: splunk_listen_interface is defined and not (splunk_listen_interface | trim) == "" - name: Set registry values ansible.windows.win_regedit: diff --git a/deployments/ansible/roles/collector/templates/splunk-otel-collector.conf.j2 b/deployments/ansible/roles/collector/templates/splunk-otel-collector.conf.j2 index 1286e2f135..7347f32ed9 100644 --- a/deployments/ansible/roles/collector/templates/splunk-otel-collector.conf.j2 +++ b/deployments/ansible/roles/collector/templates/splunk-otel-collector.conf.j2 @@ -20,7 +20,9 @@ SPLUNK_HEC_URL={{ "https://ingest." + splunk_realm + ".signalfx.com/v1/log" }} SPLUNK_HEC_TOKEN={{ splunk_hec_token }} SPLUNK_MEMORY_TOTAL_MIB={{ splunk_memory_total_mib }} SPLUNK_BALLAST_SIZE_MIB={{ splunk_ballast_size_mib }} +{% if splunk_listen_interface is defined and splunk_listen_interface %} SPLUNK_LISTEN_INTERFACE={{ splunk_listen_interface }} +{% endif %} SPLUNK_BUNDLE_DIR={{ splunk_bundle_dir }} SPLUNK_COLLECTD_DIR={{ splunk_collectd_dir }} {% if splunk_otel_collector_additional_env_vars is not none %} diff --git a/deployments/chef/CHANGELOG.md b/deployments/chef/CHANGELOG.md index 7b94671900..af73e18110 100644 --- a/deployments/chef/CHANGELOG.md +++ b/deployments/chef/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## unreleased + +- Update `splunk_listen_interface` default to only set target SPLUNK_LISTEN_INTERFACE environment variable if + configure. + ## chef-v0.7.0 - Add support for the `splunk_listen_interface` option to configure the network interface the collector receivers diff --git a/deployments/chef/attributes/default.rb b/deployments/chef/attributes/default.rb index f4a246748b..32d84db401 100644 --- a/deployments/chef/attributes/default.rb +++ b/deployments/chef/attributes/default.rb @@ -21,7 +21,7 @@ default['splunk_otel_collector']['splunk_hec_token'] = "#{node['splunk_otel_collector']['splunk_access_token']}" default['splunk_otel_collector']['splunk_memory_total_mib'] = '512' default['splunk_otel_collector']['splunk_ballast_size_mib'] = '' -default['splunk_otel_collector']['splunk_listen_interface'] = '0.0.0.0' +default['splunk_otel_collector']['splunk_listen_interface'] = '' default['splunk_otel_collector']['collector_config'] = {} diff --git a/deployments/chef/recipes/collector_win_registry.rb b/deployments/chef/recipes/collector_win_registry.rb index dfb39895e1..a6739ff5b5 100644 --- a/deployments/chef/recipes/collector_win_registry.rb +++ b/deployments/chef/recipes/collector_win_registry.rb @@ -12,11 +12,14 @@ { name: 'SPLUNK_HEC_TOKEN', type: :string, data: node['splunk_otel_collector']['splunk_hec_token'].to_s }, { name: 'SPLUNK_MEMORY_TOTAL_MIB', type: :string, data: node['splunk_otel_collector']['splunk_memory_total_mib'].to_s }, { name: 'SPLUNK_BALLAST_SIZE_MIB', type: :string, data: node['splunk_otel_collector']['splunk_ballast_size_mib'].to_s }, - { name: 'SPLUNK_LISTEN_INTERFACE', type: :string, data: node['splunk_otel_collector']['splunk_listen_interface'].to_s }, { name: 'SPLUNK_BUNDLE_DIR', type: :string, data: node['splunk_otel_collector']['splunk_bundle_dir'].to_s }, { name: 'SPLUNK_COLLECTD_DIR', type: :string, data: node['splunk_otel_collector']['splunk_collectd_dir'].to_s }, ] +unless node['splunk_otel_collector']['splunk_listen_interface'].to_s.strip.empty? + registry_values.push({ name: 'SPLUNK_LISTEN_INTERFACE', type: :string, data: node['splunk_otel_collector']['splunk_listen_interface'].to_s }) +end + node['splunk_otel_collector']['collector_additional_env_vars'].each do |key, value| registry_values.push({ name: key, type: :string, data: value.to_s }) end diff --git a/deployments/chef/templates/splunk-otel-collector.conf.erb b/deployments/chef/templates/splunk-otel-collector.conf.erb index 8b83cbad38..23f395378a 100644 --- a/deployments/chef/templates/splunk-otel-collector.conf.erb +++ b/deployments/chef/templates/splunk-otel-collector.conf.erb @@ -28,8 +28,10 @@ SPLUNK_HEC_TOKEN=<%= node['splunk_otel_collector']['splunk_hec_token'] %> # the value calculated by `SPLUNK_MEMORY_TOTAL_MIB`. SPLUNK_MEMORY_TOTAL_MIB=<%= node['splunk_otel_collector']['splunk_memory_total_mib'] %> +<% if !node['splunk_otel_collector']['splunk_listen_interface'].to_s.strip.empty? -%> # The network interface the collector receivers will listen on. SPLUNK_LISTEN_INTERFACE=<%= node['splunk_otel_collector']['splunk_listen_interface'] %> +<% end -%> # How much memory to allocate to the ballast. This should be set to 1/3 to 1/2 of configured memory. SPLUNK_BALLAST_SIZE_MIB=<%= node['splunk_otel_collector']['splunk_ballast_size_mib'] %> diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/splunk-otel-collector.nuspec b/internal/buildscripts/packaging/choco/splunk-otel-collector/splunk-otel-collector.nuspec index 328e58c068..dff564adaa 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/splunk-otel-collector.nuspec +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/splunk-otel-collector.nuspec @@ -18,7 +18,7 @@ The following package parameters are available: * `/SPLUNK_HEC_URL`: URL of the Splunk HEC endpoint (e.g. `https://ingest.us1.signalfx.com/v1/log`). Default value is `https://ingest.$SPLUNK_REALM.signalfx.com/v1/log` * `/SPLUNK_TRACE_URL`: URL of the Splunk trace endpoint (e.g. `https://ingest.us1.signalfx.com/v2/trace`). Default value is `https://ingest.$SPLUNK_REALM.signalfx.com/v2/trace` * `/SPLUNK_BUNDLE_DIR`: The path to the Smart Agent bundle directory for the `smartagent` receiver and extension. The default path is provided by the Collector package. If the specified path is changed from the default value, the path should be an existing directory on the system. Default value is `\Program Files\Splunk\OpenTelemetry Collector\agent-bundle`. - * `/SPLUNK_LISTEN_INTERFACE`: The network interface the collector receivers will listen on. Default value is `0.0.0.0`. + * `/SPLUNK_LISTEN_INTERFACE`: The network interface the collector receivers will listen on. Default value is `127.0.0.1` for agent mode and `0.0.0.0` for gateway. * `/MODE`: This parameter is used for setting the Collector configuration file to `\ProgramData\Splunk\OpenTelemetry Collector\agent_config.yaml` or `\ProgramData\Splunk\OpenTelemetry Collector\gateway_config.yaml`. Possible values are `agent` and `gateway`. Default value is `agent`. * `/WITH_FLUENTD`: Whether to download, install, and configure Fluentd to collect and forward log events to the Collector. Possible values are `true` and `false`. If set to `true`, the Fluentd MSI package will be downloaded from `https://packages.treasuredata.com`. Default value is `false`. @@ -49,4 +49,4 @@ See [Chocolatey Installation](https://github.com/signalfx/splunk-otel-collector/ - \ No newline at end of file + diff --git a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 index 3ff680425b..3bd529d2cc 100644 --- a/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 +++ b/internal/buildscripts/packaging/choco/splunk-otel-collector/tools/chocolateyinstall.ps1 @@ -135,8 +135,6 @@ try { } } catch { - $SPLUNK_LISTEN_INTERFACE = "0.0.0.0" - write-host "The SPLUNK_LISTEN_INTERFACE parameter is not specified. Using default configuration." } try { @@ -167,7 +165,9 @@ try { update_registry -path "$regkey" -name "SPLUNK_API_URL" -value "$SPLUNK_API_URL" update_registry -path "$regkey" -name "SPLUNK_BUNDLE_DIR" -value "$SPLUNK_BUNDLE_DIR" -update_registry -path "$regkey" -name "SPLUNK_LISTEN_INTERFACE" -value "$SPLUNK_LISTEN_INTERFACE" +if ($SPLUNK_LISTEN_INTERFACE) { + update_registry -path "$regkey" -name "SPLUNK_LISTEN_INTERFACE" -value "$SPLUNK_LISTEN_INTERFACE" +} update_registry -path "$regkey" -name "SPLUNK_HEC_TOKEN" -value "$SPLUNK_HEC_TOKEN" update_registry -path "$regkey" -name "SPLUNK_HEC_URL" -value "$SPLUNK_HEC_URL" update_registry -path "$regkey" -name "SPLUNK_INGEST_URL" -value "$SPLUNK_INGEST_URL" diff --git a/internal/buildscripts/packaging/installer/install.ps1 b/internal/buildscripts/packaging/installer/install.ps1 index 3af3746ea2..92672ad0c5 100644 --- a/internal/buildscripts/packaging/installer/install.ps1 +++ b/internal/buildscripts/packaging/installer/install.ps1 @@ -41,7 +41,7 @@ .EXAMPLE .\install.ps1 -access_token "ACCESSTOKEN" -mode "gateway" .PARAMETER network_interface - (OPTIONAL) The network interface the collector receivers listen on. (default: "0.0.0.0") + (OPTIONAL) The network interface the collector receivers listen on. (default: "127.0.0.1" for agent mode and "0.0.0.0" otherwise) .EXAMPLE .\install.ps1 -access_token "ACCESSTOKEN" -network_interface "127.0.0.1" .PARAMETER ingest_url @@ -113,7 +113,7 @@ param ( [string]$realm = "us0", [string]$memory = "512", [ValidateSet('agent','gateway')][string]$mode = "agent", - [string]$network_interface = "0.0.0.0", + [string]$network_interface = "", [string]$ingest_url = "", [string]$api_url = "", [string]$trace_url = "", @@ -582,7 +582,9 @@ update_registry -path "$regkey" -name "SPLUNK_HEC_TOKEN" -value "$hec_token" update_registry -path "$regkey" -name "SPLUNK_HEC_URL" -value "$hec_url" update_registry -path "$regkey" -name "SPLUNK_INGEST_URL" -value "$ingest_url" update_registry -path "$regkey" -name "SPLUNK_MEMORY_TOTAL_MIB" -value "$memory" -update_registry -path "$regkey" -name "SPLUNK_LISTEN_INTERFACE" -value "$network_interface" +if ($network_interface -Ne "") { + update_registry -path "$regkey" -name "SPLUNK_LISTEN_INTERFACE" -value "$network_interface" +} update_registry -path "$regkey" -name "SPLUNK_REALM" -value "$realm" update_registry -path "$regkey" -name "SPLUNK_TRACE_URL" -value "$trace_url" diff --git a/internal/buildscripts/packaging/installer/install.sh b/internal/buildscripts/packaging/installer/install.sh index 599d572a65..2744a18f52 100755 --- a/internal/buildscripts/packaging/installer/install.sh +++ b/internal/buildscripts/packaging/installer/install.sh @@ -671,7 +671,7 @@ Collector: --mode Configure the collector service to run in agent or gateway mode. (default: "agent") --listen-interface network interface the collector receivers listen on. - (default: "$default_listen_interface") + (default: "127.0.0.1" for agent mode and "0.0.0.0" otherwise) --realm The Splunk realm to use. The ingest, api, trace, and HEC endpoint URLs will automatically be inferred by this value. (default: "$default_realm") @@ -869,7 +869,7 @@ parse_args_and_install() { local ingest_url= local insecure= local memory="$default_memory_size" - local listen_interface="$default_listen_interface" + local listen_interface= local realm="$default_realm" local service_group="$default_service_group" local stage="$default_stage" @@ -1103,7 +1103,10 @@ parse_args_and_install() { echo "Ballast Size in MIB: $ballast" fi echo "Memory Size in MIB: $memory" - echo "Listen network interface: $listen_interface" + + if [ -n "$listen_interface" ]; then + echo "Listen network interface: $listen_interface" + fi echo "Realm: $realm" echo "Ingest Endpoint: $ingest_url" echo "API Endpoint: $api_url" @@ -1188,7 +1191,9 @@ parse_args_and_install() { rm -f "$collector_env_path" fi - configure_env_file "SPLUNK_LISTEN_INTERFACE" "$listen_interface" "$collector_env_path" + if [ -n "$listen_interface" ]; then + configure_env_file "SPLUNK_LISTEN_INTERFACE" "$listen_interface" "$collector_env_path" + fi configure_env_file "SPLUNK_CONFIG" "$collector_config_path" "$collector_env_path" configure_env_file "SPLUNK_ACCESS_TOKEN" "$access_token" "$collector_env_path" configure_env_file "SPLUNK_REALM" "$realm" "$collector_env_path" diff --git a/internal/buildscripts/packaging/tests/installer_test.py b/internal/buildscripts/packaging/tests/installer_test.py index a703c58bb4..04c74eec2d 100644 --- a/internal/buildscripts/packaging/tests/installer_test.py +++ b/internal/buildscripts/packaging/tests/installer_test.py @@ -109,7 +109,7 @@ def verify_env_file(container, mode="agent", config_path=None, memory=TOTAL_MEMO verify_config_file(container, env_path, "SPLUNK_HEC_URL", f"{ingest_url}/v1/log") verify_config_file(container, env_path, "SPLUNK_HEC_TOKEN", SPLUNK_ACCESS_TOKEN) verify_config_file(container, env_path, "SPLUNK_MEMORY_TOTAL_MIB", memory) - verify_config_file(container, env_path, "SPLUNK_LISTEN_INTERFACE", listen_addr) + verify_config_file(container, env_path, "SPLUNK_LISTEN_INTERFACE", False, False) if ballast: verify_config_file(container, env_path, "SPLUNK_BALLAST_SIZE_MIB", ballast)