Skip to content

Commit

Permalink
update installers to not use default SPLUNK_LISTEN_INTERFACE
Browse files Browse the repository at this point in the history
  • Loading branch information
rmfitzpatrick committed Oct 6, 2023
1 parent 5cebeed commit fa4375b
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions deployments/ansible/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## unreleased

### 💡 Enhancements 💡

- Only propagate `splunk_listen_interface` to target SPLUNK_LISTEN_INTERFACE service environment variable if set.

## ansible-v0.22.0

### 💡 Enhancements 💡
Expand Down
2 changes: 1 addition & 1 deletion deployments/ansible/molecule/custom_vars/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deployments/ansible/molecule/custom_vars/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion deployments/ansible/roles/collector/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions deployments/ansible/roles/collector/tasks/otel_win_reg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
5 changes: 5 additions & 0 deletions deployments/chef/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion deployments/chef/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = {}

Expand Down
5 changes: 4 additions & 1 deletion deployments/chef/recipes/collector_win_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions deployments/chef/templates/splunk-otel-collector.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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'] %>

<% unless 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'] %>
Expand Down
3 changes: 3 additions & 0 deletions deployments/puppet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- Add support for `splunk_listen_interface` used by default configurations as `SPLUNK_LISTEN_INTERFACE` environment variable.
- Update fluentd url for Windows.

## puppet-v0.10.0

- **Breaking Changes**: Fluentd installation ***disabled*** by default.
Expand Down
2 changes: 2 additions & 0 deletions deployments/puppet/manifests/collector_win_registry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
require => Registry_key[$registry_key],
}

unless $splunk_otel_collector::splunk_listen_interface.strip().empty {
registry_value { "${registry_key}\\SPLUNK_LISTEN_INTERFACE":
ensure => 'present',
type => 'string',
data => $splunk_otel_collector::splunk_listen_interface,
require => Registry_key[$registry_key],
}
}

registry_value { "${registry_key}\\SPLUNK_BUNDLE_DIR":
ensure => 'present',
Expand Down
2 changes: 1 addition & 1 deletion deployments/puppet/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$splunk_collectd_dir = $splunk_otel_collector::params::splunk_collectd_dir,
$splunk_memory_total_mib = '512',
$splunk_ballast_size_mib = '',
$splunk_listen_interface = '0.0.0.0',
$splunk_listen_interface = '',
$collector_version = $splunk_otel_collector::params::collector_version,
$collector_config_source = $splunk_otel_collector::params::collector_config_source,
$collector_config_dest = $splunk_otel_collector::params::collector_config_dest,
Expand Down
2 changes: 2 additions & 0 deletions deployments/puppet/templates/splunk-otel-collector.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ SPLUNK_HEC_TOKEN=<%= @splunk_hec_token %>
SPLUNK_HEC_URL=<%= @splunk_hec_url %>
SPLUNK_INGEST_URL=<%= @splunk_ingest_url %>
SPLUNK_MEMORY_TOTAL_MIB=<%= @splunk_memory_total_mib %>
<% unless @splunk_listen_interface.to_s.strip.empty? -%>
SPLUNK_LISTEN_INTERFACE=<%= @splunk_listen_interface %>
<% end -%>
SPLUNK_REALM=<%= @splunk_realm %>
SPLUNK_TRACE_URL=<%= @splunk_trace_url %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down Expand Up @@ -49,4 +49,4 @@ See [Chocolatey Installation](https://github.com/signalfx/splunk-otel-collector/
<file src="tools\**" target="tools" />
<!--Building from Linux? You may need this instead: <file src="tools/**" target="tools" />-->
</files>
</package>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 7 additions & 5 deletions internal/buildscripts/packaging/installer/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = "",
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -701,6 +703,6 @@ if ($with_fluentd) {
echo "- Started"
}

if ($network_interface -Eq "0.0.0.0") {
echo "[NOTICE] Starting with version 0.86.0, the collector installer will change its default network listening interface from 0.0.0.0 to 127.0.0.1. Please consult the release notes for more information and configuration options."
if (($network_interface -Eq "") -And ($mode -Eq "agent")) {
echo "[NOTICE] Starting with version 0.86.0, the collector installer changed its default network listening interface from 0.0.0.0 to 127.0.0.1 for agent mode. Please consult the release notes for more information and configuration options."
}
13 changes: 9 additions & 4 deletions internal/buildscripts/packaging/installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ Collector:
--mode <agent|gateway> Configure the collector service to run in agent or gateway mode.
(default: "agent")
--listen-interface <ip> 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 <us0|us1|eu0|...> The Splunk realm to use. The ingest, api, trace, and HEC endpoint URLs will
automatically be inferred by this value.
(default: "$default_realm")
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit fa4375b

Please sign in to comment.