summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike van Goor <mvangoor@schubergphilis.com>2021-11-24 09:46:45 +0100
committerMike van Goor <mvangoor@schubergphilis.com>2021-11-24 09:46:45 +0100
commit42f707b3418758a9b4c42a378c0824439efba695 (patch)
tree46724f74c2b6120dacfc031b34b69373492e3827
parentc615ae3d594ee26746d547f3e25d299645e48190 (diff)
downloadchef-42f707b3418758a9b4c42a378c0824439efba695.tar.gz
Add the data collector config items for the use case the chef infra server cannot talk to automate or running chef solo
Signed-off-by: Mike van Goor <mvangoor@schubergphilis.com>
-rw-r--r--lib/chef/resource/chef_client_config.rb21
-rw-r--r--lib/chef/resource/support/client.erb7
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/chef/resource/chef_client_config.rb b/lib/chef/resource/chef_client_config.rb
index bd4ccbc478..aa42bee862 100644
--- a/lib/chef/resource/chef_client_config.rb
+++ b/lib/chef/resource/chef_client_config.rb
@@ -87,6 +87,17 @@ class Chef
]
end
```
+
+ **Report directly to the [Chef Automate data collector endpoint](/automate/data_collection/#configure-chef-infra-client-to-use-the-data-collector-endpoint-in-chef-automate).**
+
+ ```ruby
+ chef_client_config 'Create client.rb' do
+ chef_server_url 'https://chef.example.dmz'
+ data_collector_server_url 'https://automate.example.dmz'
+ data_collector_token 'TEST_TOKEN_TEST'
+ end
+ ```
+
DOC
# @todo policy_file or policy_group being set requires the other to be set so enforce that.
@@ -231,6 +242,12 @@ class Chef
property :additional_config, String,
description: "Additional text to add at the bottom of the client.rb config. This can be used to run custom Ruby or to add less common config options"
+ property :data_collector_server_url, String,
+ description: "The data collector url (typically automate) to send node, converge and compliance data. Note: Data collection reporting to Automate should be performed directly by Chef Infra Server if possible, as this removes the need to distribute tokens to individual nodes."
+
+ property :data_collector_token, String,
+ description: "The data collector token to interact with the data collector server url (Automate). Note: Data collection reporting to Automate should be performed directly by Chef Infra Server if possible, as this removes the need to distribute tokens to individual nodes."
+
action :create, description: "Create a client.rb config file for configuring #{ChefUtils::Dist::Infra::PRODUCT}." do
unless ::Dir.exist?(new_resource.config_directory)
directory new_resource.config_directory do
@@ -282,7 +299,9 @@ class Chef
ssl_verify_mode: new_resource.ssl_verify_mode,
start_handlers: format_handler(new_resource.start_handlers),
additional_config: new_resource.additional_config,
- policy_persist_run_list: new_resource.policy_persist_run_list
+ policy_persist_run_list: new_resource.policy_persist_run_list,
+ data_collector_server_url: new_resource.data_collector_server_url,
+ data_collector_token: new_resource.data_collector_token
)
mode "0640"
action :create
diff --git a/lib/chef/resource/support/client.erb b/lib/chef/resource/support/client.erb
index 0a0db02249..8e96ca49e2 100644
--- a/lib/chef/resource/support/client.erb
+++ b/lib/chef/resource/support/client.erb
@@ -37,6 +37,13 @@ log_location <%= @log_location %>
log_location <%= @log_location.inspect %>
<% end -%>
<% end -%>
+<%# These data_collector options are special as they have a '.' -%>
+<% unless @data_collector_server_url.nil? || @data_collector_server_url.empty? %>
+data_collector.server_url <%= @data_collector_server_url %>
+<% end %>
+<% unless @data_collector_token.nil? || @data_collector_token.empty? %>
+data_collector.token <%= @data_collector_token %>
+<% end %>
<%# The code below is not DRY on purpose to improve readability -%>
<% unless @start_handlers.empty? -%>
# Do not crash if a start handler is missing / not installed yet