Add support to `extra_config` on `process_config` section
MODIFY
spec/dd-agent_spec.rb
spec/dd-agent_spec.rb
@@ -1001,6 +1001,67 @@ describe 'datadog::dd-agent' do
end
end
end
+
+ context 'with extra_config params set' do
+ cached(:chef_run) do
+ ChefSpec::SoloRunner.new(
+ platform: 'ubuntu',
+ version: '14.04'
+ ) do |node|
+ node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml`
+ node.normal['datadog'] = {
+ 'api_key' => 'somethingnotnil',
+ 'agent6' => true,
+ 'extra_config' => {
+ 'secret_backend_command' => '/sbin/local-secrets',
+ 'process_config' => {
+ 'custom_param' => 'somethingnotnil'
+ }
+ }
+ }
+ end.converge described_recipe
+ end
+
+ it 'is created' do
+ expect(chef_run).to create_template('/etc/datadog-agent/datadog.yaml')
+ end
+
+ it 'contains expected YAML configuration' do
+ expected_yaml = <<-EOF
+ api_key: somethingnotnil
+ tags: []
+ use_dogstatsd: true
+ bind_host: localhost
+ additional_endpoints: {}
+ secret_backend_command: /sbin/local-secrets
+ histogram_aggregates:
+ - "max"
+ - "median"
+ - "avg"
+ - "count"
+ histogram_percentiles:
+ - "0.95"
+ hostname: "chef-nodename"
+ log_file: "/var/log/datadog/agent.log"
+ log_level: "INFO"
+ dogstatsd_non_local_traffic: false
+ apm_config:
+ apm_non_local_traffic: false
+ process_config:
+ enabled: "false"
+ blacklist_patterns: []
+ scrub_args: true
+ custom_sensitive_words: []
+ intervals: {}
+ process_dd_url: "https://process.datadoghq.com"
+ custom_param: somethingnotnil
+ EOF
+
+ expect(chef_run).to(render_file('/etc/datadog-agent/datadog.yaml').with_content { |content|
+ expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json)
+ })
+ end
+ end
end
describe 'agent version set' do

MODIFY
templates/default/datadog.yaml.erb
templates/default/datadog.yaml.erb
@@ -93,22 +93,6 @@ agent_config = @extra_config.merge({
# log agent options
logs_enabled: node['datadog']['enable_logs_agent'],
-
- # process agent options
- process_config: {
- enabled: process_agent_enabled,
- log_file: node['datadog']['process_agent']['log_file'],
- intervals: {
- container: node['datadog']['process_agent']['container_interval'],
- container_realtime: node['datadog']['process_agent']['rtcontainer_interval'],
- process: node['datadog']['process_agent']['rtcontainer_interval'],
- process_realtime: node['datadog']['process_agent']['rtprocess_interval'],
- },
- blacklist_patterns: node['datadog']['process_agent']['blacklist'],
- scrub_args: node['datadog']['process_agent']['scrub_args'],
- custom_sensitive_words: node['datadog']['process_agent']['custom_sensitive_words'],
- process_dd_url: node['datadog']['process_agent']['url']
- }
})
if node['datadog']['statsd_forward_host']
@@ -142,6 +126,28 @@ if !http_proxy.nil?
agent_config['proxy']['no_proxy'] = no_proxy if !no_proxy.nil?
end
+## Process agent options ##
+process_config = {
+ enabled: process_agent_enabled,
+ log_file: node['datadog']['process_agent']['log_file'],
+ intervals: {
+ container: node['datadog']['process_agent']['container_interval'],
+ container_realtime: node['datadog']['process_agent']['rtcontainer_interval'],
+ process: node['datadog']['process_agent']['rtcontainer_interval'],
+ process_realtime: node['datadog']['process_agent']['rtprocess_interval'],
+ },
+ blacklist_patterns: node['datadog']['process_agent']['blacklist'],
+ scrub_args: node['datadog']['process_agent']['scrub_args'],
+ custom_sensitive_words: node['datadog']['process_agent']['custom_sensitive_words'],
+ process_dd_url: node['datadog']['process_agent']['url']
+}
+
+# Take into account options defined under ['extra_config']['process_config']
+process_config = @extra_config['process_config'].merge(process_config) unless @extra_config['process_config'].nil?
+agent_config[:process_config] = process_config
+agent_config[:process_config][:intervals].reject!{ |k,v| v.nil? }
+agent_config[:process_config].reject!{ |k,v| v.nil? }
+
## Trace agent options ##
apm_config = {
enabled: node['datadog']['enable_trace_agent'],
@@ -156,10 +162,7 @@ apm_config.reject!{ |k,v| v.nil? }
apm_config = @extra_config['apm_config'].merge(apm_config) unless @extra_config['apm_config'].nil?
agent_config[:apm_config] = apm_config
-
# Remove nil values
-agent_config[:process_config][:intervals].reject!{ |k,v| v.nil? }
-agent_config[:process_config].reject!{ |k,v| v.nil? }
agent_config.reject!{ |k,v| v.nil? }
-%>

Add support to `extra_config` on `process_config` section