summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-10-14 12:53:08 -0700
committerGitHub <noreply@github.com>2020-10-14 12:53:08 -0700
commit783b78fc75c75feb3aaf85316e21bc5becd6aa9d (patch)
tree0810a5e76803c353d4036749c068653f35bbfd18
parent099f99848d00db55e5f9a1aa737c81a80af9a550 (diff)
parent6d351c90b22f804f5cbc00c43a10ca464397fbbd (diff)
downloadchef-783b78fc75c75feb3aaf85316e21bc5becd6aa9d.tar.gz
Merge pull request #10418 from chef/lcg/ohai-target-mode
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/application/client.rb7
-rw-r--r--lib/chef/client.rb33
2 files changed, 8 insertions, 32 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 4a749a7c39..39ae7adaac 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -27,6 +27,7 @@ module Mixlib
autoload :Log, "mixlib/authentication"
end
end
+autoload :Train, "train"
# DO NOT MAKE EDITS, see Chef::Application::Base
#
@@ -115,8 +116,12 @@ class Chef::Application::Client < Chef::Application::Base
Chef::Config.chef_zero.port = config[:chef_zero_port] if config[:chef_zero_port]
if config[:target] || Chef::Config.target
- Chef::Config.target_mode.enabled = true
Chef::Config.target_mode.host = config[:target] || Chef::Config.target
+ if URI.parse(Chef::Config.target_mode.host).scheme
+ train_config = Train.unpack_target_from_uri(Chef::Config.target_mode.host)
+ Chef::Config.target_mode = train_config
+ end
+ Chef::Config.target_mode.enabled = true
Chef::Config.node_name = Chef::Config.target_mode.host unless Chef::Config.node_name
end
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 04d907634b..41e3846812 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -251,11 +251,7 @@ class Chef
logger.debug("#{ChefUtils::Dist::Infra::CLIENT.capitalize} request_id: #{request_id}")
ENV["PATH"] = ChefUtils::DSL::DefaultPaths.default_paths if Chef::Config[:enforce_default_paths] || Chef::Config[:enforce_path_sanity]
- if Chef::Config.target_mode?
- get_ohai_data_remotely
- else
- run_ohai
- end
+ run_ohai
unless Chef::Config[:solo_legacy_mode]
register
@@ -576,32 +572,6 @@ class Chef
end
#
- # Populate the minimal ohai attributes defined in #run_ohai with data train collects.
- #
- # Eventually ohai may support colleciton of data.
- #
- def get_ohai_data_remotely
- ohai.data[:fqdn] = if transport_connection.respond_to?(:hostname)
- transport_connection.hostname
- else
- Chef::Config[:target_mode][:host]
- end
- if transport_connection.respond_to?(:os)
- ohai.data[:platform] = transport_connection.os.name
- ohai.data[:platform_version] = transport_connection.os.release
- ohai.data[:os] = transport_connection.os.family_hierarchy[1]
- ohai.data[:platform_family] = transport_connection.os.family
- end
- # train does not collect these specifically
- # ohai.data[:machinename] = nil
- # ohai.data[:hostname] = nil
- # ohai.data[:os_version] = nil # kernel version
-
- ohai.data[:ohai_time] = Time.now.to_f
- events.ohai_completed(node)
- end
-
- #
# Run ohai plugins. Runs all ohai plugins unless minimal_ohai is specified.
#
# Sends the ohai_completed event when finished.
@@ -613,6 +583,7 @@ class Chef
#
def run_ohai
filter = Chef::Config[:minimal_ohai] ? %w{fqdn machinename hostname platform platform_version ohai_time os os_version init_package} : nil
+ ohai.transport_connection = transport_connection if Chef::Config.target_mode?
ohai.all_plugins(filter)
events.ohai_completed(node)
end