diff --git a/deployments/chef/kitchen.windows.yml b/deployments/chef/kitchen.windows.yml index a1c95d267f..4dd1a831ba 100644 --- a/deployments/chef/kitchen.windows.yml +++ b/deployments/chef/kitchen.windows.yml @@ -54,6 +54,7 @@ suites: splunk_api_url: https://fake-splunk-api.com splunk_memory_total_mib: "256" splunk_hec_token: fake-hec-token + splunk_listen_interface: "0.0.0.0" collector_version: 0.48.0 collector_additional_env_vars: MY_CUSTOM_VAR1: value1 diff --git a/deployments/chef/kitchen.yml b/deployments/chef/kitchen.yml index 2be53600ab..0811c02a4c 100644 --- a/deployments/chef/kitchen.yml +++ b/deployments/chef/kitchen.yml @@ -153,6 +153,7 @@ suites: splunk_api_url: https://fake-splunk-api.com splunk_memory_total_mib: "256" splunk_hec_token: fake-hec-token + splunk_listen_interface: "0.0.0.0" user: custom-user group: custom-group collector_additional_env_vars: diff --git a/deployments/chef/test/integration/custom_vars/inspec/custom_vars_spec.rb b/deployments/chef/test/integration/custom_vars/inspec/custom_vars_spec.rb index 40f2cf64eb..26058d9bbe 100644 --- a/deployments/chef/test/integration/custom_vars/inspec/custom_vars_spec.rb +++ b/deployments/chef/test/integration/custom_vars/inspec/custom_vars_spec.rb @@ -6,6 +6,7 @@ splunk_hec_url = "#{splunk_ingest_url}/v1/log" splunk_hec_token = 'fake-hec-token' splunk_memory_total = '256' +splunk_listen_interface = '0.0.0.0' describe service('splunk-otel-collector') do it { should be_enabled } @@ -25,6 +26,7 @@ its('SPLUNK_HEC_TOKEN') { should eq splunk_hec_token } its('SPLUNK_HEC_URL') { should eq splunk_hec_url } its('SPLUNK_INGEST_URL') { should eq splunk_ingest_url } + its('SPLUNK_LISTEN_INTERFACE') { should eq splunk_listen_interface } its('SPLUNK_MEMORY_TOTAL_MIB') { should eq splunk_memory_total } its('SPLUNK_REALM') { should eq splunk_realm } its('SPLUNK_TRACE_URL') { should eq splunk_trace_url } @@ -48,6 +50,7 @@ its('content') { should match /^SPLUNK_HEC_TOKEN=#{splunk_hec_token}$/ } its('content') { should match /^SPLUNK_HEC_URL=#{splunk_hec_url}$/ } its('content') { should match /^SPLUNK_INGEST_URL=#{splunk_ingest_url}$/ } + its('content') { should match /^SPLUNK_LISTEN_INTERFACE=#{splunk_listen_interface}$/ } its('content') { should match /^SPLUNK_MEMORY_TOTAL_MIB=#{splunk_memory_total}$/ } its('content') { should match /^SPLUNK_REALM=test$/ } its('content') { should match /^SPLUNK_TRACE_URL=#{splunk_trace_url}$/ } diff --git a/deployments/chef/test/integration/default/inspec/default_spec.rb b/deployments/chef/test/integration/default/inspec/default_spec.rb index 36712d719b..0392986bbd 100644 --- a/deployments/chef/test/integration/default/inspec/default_spec.rb +++ b/deployments/chef/test/integration/default/inspec/default_spec.rb @@ -28,6 +28,7 @@ its('SPLUNK_MEMORY_TOTAL_MIB') { should eq splunk_memory_total } its('SPLUNK_REALM') { should eq splunk_realm } its('SPLUNK_TRACE_URL') { should eq splunk_trace_url } + it { should_not have_property('SPLUNK_LISTEN_INTERFACE') } end describe service('fluentdwinsvc') do it { should_not be_enabled } @@ -49,6 +50,7 @@ its('content') { should match /^SPLUNK_MEMORY_TOTAL_MIB=#{splunk_memory_total}$/ } its('content') { should match /^SPLUNK_REALM=test$/ } its('content') { should match /^SPLUNK_TRACE_URL=#{splunk_trace_url}$/ } + its('content') { should_not match /^SPLUNK_LISTEN_INTERFACE=.*$/ } end describe file('/etc/systemd/system/splunk-otel-collector.service.d/service-owner.conf') do its('content') { should match /^User=splunk-otel-collector$/ } diff --git a/internal/buildscripts/packaging/tests/deployments/puppet/puppet_test.py b/internal/buildscripts/packaging/tests/deployments/puppet/puppet_test.py index 99d7126a4e..9536add54d 100644 --- a/internal/buildscripts/packaging/tests/deployments/puppet/puppet_test.py +++ b/internal/buildscripts/packaging/tests/deployments/puppet/puppet_test.py @@ -80,6 +80,7 @@ def verify_env_file(container): run_container_cmd(container, f"grep '^SPLUNK_INGEST_URL={SPLUNK_INGEST_URL}$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_REALM={SPLUNK_REALM}$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_TRACE_URL={SPLUNK_INGEST_URL}/v2/trace$' {SPLUNK_ENV_PATH}") + assert container.exec_run(f"grep '^SPLUNK_LISTEN_INTERFACE=.*' {SPLUNK_ENV_PATH}").exit_code != 0 def skip_if_necessary(distro, puppet_release): @@ -234,6 +235,7 @@ class {{ splunk_otel_collector: splunk_api_url => '$api_url', splunk_ingest_url => '$ingest_url', splunk_hec_token => 'fake-hec-token', + splunk_listen_interface => '0.0.0.0', collector_version => '$version', with_fluentd => $fluentd, collector_additional_env_vars => {{ 'MY_CUSTOM_VAR1' => 'value1', 'MY_CUSTOM_VAR2' => 'value2' }}, @@ -268,6 +270,7 @@ def test_puppet_with_custom_vars(distro, puppet_release): run_container_cmd(container, f"grep '^SPLUNK_HEC_TOKEN=fake-hec-token$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_HEC_URL={ingest_url}/v1/log$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_INGEST_URL={ingest_url}$' {SPLUNK_ENV_PATH}") + run_container_cmd(container, f"grep '^SPLUNK_LISTEN_INTERFACE=0.0.0.0$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_REALM={SPLUNK_REALM}$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_TRACE_URL={ingest_url}/v2/trace$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^MY_CUSTOM_VAR1=value1$' {SPLUNK_ENV_PATH}") @@ -327,6 +330,11 @@ def test_win_puppet_default(): assert get_registry_value("SPLUNK_HEC_URL") == f"{SPLUNK_INGEST_URL}/v1/log" assert get_registry_value("SPLUNK_TRACE_URL") == f"{SPLUNK_INGEST_URL}/v2/trace" assert get_registry_value("SPLUNK_HEC_TOKEN") == SPLUNK_ACCESS_TOKEN + try: + listen_interface = get_registry_value("SPLUNK_LISTEN_INTERFACE") + except FileNotFoundError: + listen_interface = None + assert listen_interface is None assert psutil.win_service_get("splunk-otel-collector").status() == psutil.STATUS_RUNNING for service in psutil.win_service_iter(): @@ -349,6 +357,7 @@ def test_win_puppet_custom_vars(): assert get_registry_value("SPLUNK_API_URL") == api_url assert get_registry_value("SPLUNK_INGEST_URL") == ingest_url assert get_registry_value("SPLUNK_HEC_URL") == f"{ingest_url}/v1/log" + assert get_registry_value("SPLUNK_LISTEN_INTERFACE") == "0.0.0.0" assert get_registry_value("SPLUNK_TRACE_URL") == f"{ingest_url}/v2/trace" assert get_registry_value("SPLUNK_HEC_TOKEN") == "fake-hec-token" assert get_registry_value("MY_CUSTOM_VAR1") == "value1" diff --git a/internal/buildscripts/packaging/tests/deployments/salt/salt_test.py b/internal/buildscripts/packaging/tests/deployments/salt/salt_test.py index 9092ffd686..24fb956229 100644 --- a/internal/buildscripts/packaging/tests/deployments/salt/salt_test.py +++ b/internal/buildscripts/packaging/tests/deployments/salt/salt_test.py @@ -76,7 +76,7 @@ def run_salt_apply(container, config): run_container_cmd(container, SALT_CMD) -def verify_env_file(container): +def verify_env_file(container, listen_interface=None): run_container_cmd(container, f"grep '^SPLUNK_CONFIG={SPLUNK_CONFIG}$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_ACCESS_TOKEN={SPLUNK_ACCESS_TOKEN}$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_REALM={SPLUNK_REALM}$' {SPLUNK_ENV_PATH}") @@ -88,6 +88,10 @@ def verify_env_file(container): run_container_cmd(container, f"grep '^SPLUNK_MEMORY_TOTAL_MIB={SPLUNK_MEMORY_TOTAL_MIB}$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_BUNDLE_DIR={SPLUNK_BUNDLE_DIR}$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^SPLUNK_COLLECTD_DIR={SPLUNK_COLLECTD_DIR}$' {SPLUNK_ENV_PATH}") + if listen_interface: + run_container_cmd(container, f"grep '^SPLUNK_LISTEN_INTERFACE={listen_interface}$' {SPLUNK_ENV_PATH}") + else: + assert container.exec_run(f"grep '^SPLUNK_LISTEN_INTERFACE=.*' {SPLUNK_ENV_PATH}").exit_code != 0 @pytest.mark.salt @@ -268,6 +272,7 @@ def test_salt_service_owner(distro): splunk-otel-collector: splunk_access_token: '{SPLUNK_ACCESS_TOKEN}' splunk_realm: '{SPLUNK_REALM}' + splunk_listen_interface: '0.0.0.0' collector_additional_env_vars: MY_CUSTOM_VAR1: value1 MY_CUSTOM_VAR2: value2 @@ -289,7 +294,7 @@ def test_salt_custom_env_vars(distro): with run_distro_container(distro, dockerfile=dockerfile, path=REPO_DIR) as container: try: run_salt_apply(container, CUSTOM_ENV_VARS_CONFIG) - verify_env_file(container) + verify_env_file(container, listen_interface="0.0.0.0") run_container_cmd(container, f"grep '^MY_CUSTOM_VAR1=value1$' {SPLUNK_ENV_PATH}") run_container_cmd(container, f"grep '^MY_CUSTOM_VAR2=value2$' {SPLUNK_ENV_PATH}") assert wait_for(lambda: service_is_running(container))