Module: Chef::DataCollector::RunStartMessage

Extended by:
MessageHelpers
Defined in:
lib/chef/data_collector/run_start_message.rb

Class Method Summary collapse

Class Method Details

.construct_message(data_collector) ⇒ Hash

Construct the message payload that is sent to the DataCollector server at the start of a Chef run.

Parameters:

Returns:

  • (Hash)

    A hash containing the run start message data.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/chef/data_collector/run_start_message.rb', line 41

def construct_message(data_collector)
  run_status = data_collector.run_status
  node = data_collector.node
  {
    "chef_server_fqdn" => URI(Chef::Config[:chef_server_url]).host,
    "entity_uuid" => Chef::Config[:chef_guid],
    "id" => run_status&.run_id,
    "message_version" => "1.0.0",
    "message_type" => "run_start",
    "node_name" => node&.name || data_collector.node_name,
    "organization_name" => organization,
    "run_id" => run_status&.run_id,
    "source" => solo_run? ? "chef_solo" : "chef_client",
    "start_time" => run_status&.start_time&.utc&.iso8601,
  }
end