Ensure NPM is not turned off by default when system probe is enabled
MODIFY
attributes/default.rb
attributes/default.rb
@@ -366,6 +366,8 @@ default['datadog']['process_agent']['rtcontainer_interval'] = nil
# Whether this cookbook should write system-probe.yaml or not.
# If set to false all other system-probe settings are ignored
default['datadog']['system_probe']['manage_config'] = true
+# When `system_probe.enabled` is set to false and `network_enabled` is set to true,
+# the NPM module of system probe will still run.
default['datadog']['system_probe']['enabled'] = false
# sysprobe_socket defines the unix socket location
default['datadog']['system_probe']['sysprobe_socket'] = '/opt/datadog-agent/run/sysprobe.sock'
@@ -376,7 +378,9 @@ default['datadog']['system_probe']['enable_conntrack'] = false
# Enable this switch will install NPM driver and sysprobe, as well as generate the config file.
# Turning on this setting will effectively turn on the setting(s) automatically:
# ['datadog']['system_probe']['enabled']
-default['datadog']['system_probe']['network_enabled'] = false
+# When this is set to nil (default), `network_config` won't be rendered in system-probe.yaml,
+# making the Agent use the default setting for this value.
+default['datadog']['system_probe']['network_enabled'] = nil
# Logs functionality settings (Agent 6/7 only)
# Set `enable_logs_agent` to:

MODIFY
spec/system-probe_spec.rb
spec/system-probe_spec.rb
@@ -32,6 +32,55 @@ describe 'datadog::system-probe' do
end
end
+ context 'with network_enabled set to true' do
+ cached(:solo) do
+ ChefSpec::SoloRunner.new(
+ platform: 'ubuntu',
+ version: '16.04'
+ ) do |node|
+ node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml`
+ node.normal['datadog'] = {
+ 'api_key' => 'somethingnotnil',
+ 'agent_major_version' => 6,
+ 'system_probe' => {
+ 'debug_port' => 123,
+ 'bpf_debug' => true,
+ 'sysprobe_socket' => '/test/ing.sock',
+ 'network_enabled' => true,
+ }
+ }
+ end
+ end
+
+ cached(:chef_run) do
+ solo.converge(described_recipe) do
+ solo.resource_collection.insert(
+ Chef::Resource::Service.new('datadog-agent', solo.run_context))
+ end
+ end
+
+ it 'is created with enabled network_config' do
+ expect(chef_run).to create_template('/etc/datadog-agent/system-probe.yaml')
+ end
+
+ it 'contains expected YAML configuration' do
+ expected_yaml = <<-EOF
+ network_config:
+ enabled: true
+ system_probe_config:
+ bpf_debug: true
+ debug_port: 123
+ enable_conntrack: false
+ enabled: false
+ sysprobe_socket: "/test/ing.sock"
+ EOF
+
+ expect(chef_run).to(render_file('/etc/datadog-agent/system-probe.yaml').with_content { |content|
+ expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json)
+ })
+ end
+ end
+
context 'with system-probe enabled' do
cached(:solo) do
ChefSpec::SoloRunner.new(
@@ -65,8 +114,6 @@ describe 'datadog::system-probe' do
it 'contains expected YAML configuration' do
expected_yaml = <<-EOF
- network_config:
- enabled: false
system_probe_config:
bpf_debug: true
debug_port: 123
@@ -116,8 +163,6 @@ describe 'datadog::system-probe' do
it 'contains expected YAML configuration' do
expected_yaml = <<-EOF
- network_config:
- enabled: false
system_probe_config:
bpf_debug: false
debug_port: 0

MODIFY
templates/default/system_probe.yaml.erb
templates/default/system_probe.yaml.erb
@@ -8,10 +8,15 @@ system_probe_config = {
bpf_debug: @bpf_debug,
enable_conntrack: @enable_conntrack,
}.merge(@extra_config),
- network_config: {
- enabled: node['datadog']['system_probe']['network_enabled'],
}
+
+# We let the Agent default value take effect if user didn't explicitly
+# specify something else than nil for 'network_enabled'
+if !node['datadog']['system_probe']['network_enabled'].nil?
+ system_probe_config['network_config'] = {
+ 'enabled': node['datadog']['system_probe']['network_enabled'],
}
+end
-%>
# Generated by Chef, local modifications will be overwritten

Ensure NPM is not turned off by default when system probe is enabled (#799)