chef 15.4.45-universal-mingw32 → 15.5.9-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -3
- data/Rakefile +5 -3
- data/chef.gemspec +2 -1
- data/ext/win32-eventlog/Rakefile +9 -1
- data/ext/win32-eventlog/{chef-log.man → chef-log.man.erb} +4 -4
- data/lib/chef/application.rb +2 -2
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -0
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/chef_class.rb +1 -6
- data/lib/chef/chef_fs.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +2 -2
- data/lib/chef/client.rb +4 -5
- data/lib/chef/config.rb +3 -2
- data/lib/chef/cookbook/chefignore.rb +16 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +5 -3
- data/lib/chef/cookbook_loader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/data_collector.rb +2 -2
- data/lib/chef/data_collector/run_end_message.rb +1 -0
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/dsl/core.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +9 -18
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/file_content_management/deploy.rb +3 -3
- data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/knife.rb +4 -3
- data/lib/chef/knife/config_get.rb +2 -1
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +6 -0
- data/lib/chef/local_mode.rb +1 -1
- data/lib/chef/mash.rb +21 -232
- data/lib/chef/mixin/file_class.rb +2 -2
- data/lib/chef/mixin/lazy_module_include.rb +1 -1
- data/lib/chef/mixin/path_sanity.rb +3 -39
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +4 -5
- data/lib/chef/mixin/template.rb +1 -1
- data/lib/chef/mixin/user_context.rb +3 -3
- data/lib/chef/mixin/which.rb +10 -38
- data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
- data/lib/chef/mixin/windows_env_helper.rb +5 -5
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node_map.rb +17 -4
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +14 -85
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/link.rb +3 -3
- data/lib/chef/provider/mount/solaris.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file/fetcher.rb +2 -2
- data/lib/chef/provider/remote_file/local_file.rb +1 -1
- data/lib/chef/provider/script.rb +3 -3
- data/lib/chef/provider/service.rb +5 -2
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +4 -4
- data/lib/chef/provider/service/init.rb +1 -1
- data/lib/chef/provider/service/insserv.rb +4 -4
- data/lib/chef/provider/service/invokercd.rb +4 -4
- data/lib/chef/provider/service/redhat.rb +4 -4
- data/lib/chef/provider/service/systemd.rb +19 -3
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/subversion.rb +1 -1
- data/lib/chef/provider/systemd_unit.rb +26 -2
- data/lib/chef/provider/windows_path.rb +3 -3
- data/lib/chef/provider/windows_task.rb +4 -4
- data/lib/chef/resource.rb +1 -0
- data/lib/chef/resource/bash.rb +2 -0
- data/lib/chef/resource/batch.rb +2 -0
- data/lib/chef/resource/breakpoint.rb +3 -1
- data/lib/chef/resource/build_essential.rb +3 -3
- data/lib/chef/resource/chef_sleep.rb +70 -0
- data/lib/chef/resource/cookbook_file.rb +2 -1
- data/lib/chef/resource/csh.rb +2 -0
- data/lib/chef/resource/directory.rb +2 -0
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +1 -1
- data/lib/chef/resource/execute.rb +2 -0
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +3 -1
- data/lib/chef/resource/ksh.rb +2 -0
- data/lib/chef/resource/link.rb +4 -2
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/log.rb +2 -0
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/perl.rb +2 -0
- data/lib/chef/resource/python.rb +2 -0
- data/lib/chef/resource/reboot.rb +2 -0
- data/lib/chef/resource/registry_key.rb +2 -0
- data/lib/chef/resource/remote_directory.rb +3 -2
- data/lib/chef/resource/remote_file.rb +1 -0
- data/lib/chef/resource/ruby.rb +2 -0
- data/lib/chef/resource/ruby_block.rb +2 -0
- data/lib/chef/resource/scm.rb +2 -0
- data/lib/chef/resource/script.rb +2 -0
- data/lib/chef/resource/service.rb +9 -1
- data/lib/chef/resource/solaris_package.rb +1 -1
- data/lib/chef/resource/subversion.rb +2 -0
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/systemd_unit.rb +1 -0
- data/lib/chef/resource/template.rb +2 -0
- data/lib/chef/resource/user.rb +2 -0
- data/lib/chef/resource/user/aix_user.rb +2 -0
- data/lib/chef/resource/user/linux_user.rb +2 -0
- data/lib/chef/resource/user/pw_user.rb +2 -0
- data/lib/chef/resource/user/solaris_user.rb +2 -0
- data/lib/chef/resource/user/windows_user.rb +2 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +1 -1
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +1 -1
- data/lib/chef/resource/windows_firewall_rule.rb +11 -6
- data/lib/chef/resource/windows_script.rb +3 -1
- data/lib/chef/resource/yum_package.rb +1 -1
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +1 -1
- data/lib/chef/run_lock.rb +5 -5
- data/lib/chef/search/query.rb +0 -3
- data/lib/chef/train_transport.rb +3 -1
- data/lib/chef/util/powershell/ps_credential.rb +2 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/logon_session.rb +2 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/eventlog.rb +2 -2
- data/spec/data/cookbooks/starter/chefignore +8 -0
- data/spec/data/cookbooks/starter/files/sample.txt +1 -0
- data/spec/data/cookbooks/starter/metadata.rb +2 -0
- data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
- data/spec/functional/mixin/user_context_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/cookbook_file_spec.rb +2 -2
- data/spec/functional/resource/template_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/functional/win32/sid_spec.rb +2 -2
- data/spec/functional/win32/version_info_spec.rb +1 -1
- data/spec/functional/win32/versions_spec.rb +1 -1
- data/spec/integration/knife/config_get_profile_spec.rb +2 -2
- data/spec/integration/knife/config_get_spec.rb +9 -2
- data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
- data/spec/integration/knife/config_use_profile_spec.rb +2 -2
- data/spec/integration/knife/list_spec.rb +2 -2
- data/spec/integration/solo/solo_spec.rb +1 -1
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/support/mock/platform.rb +1 -1
- data/spec/support/platform_helpers.rb +2 -0
- data/spec/support/shared/integration/integration_helper.rb +1 -1
- data/spec/support/shared/integration/knife_support.rb +1 -1
- data/spec/support/shared/unit/provider/file.rb +4 -4
- data/spec/unit/application/client_spec.rb +2 -2
- data/spec/unit/application/knife_spec.rb +17 -0
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
- data/spec/unit/chef_fs/path_util_spec.rb +3 -3
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/cookbook/chefignore_spec.rb +31 -11
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
- data/spec/unit/cookbook_loader_spec.rb +2 -2
- data/spec/unit/cookbook_uploader_spec.rb +6 -1
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +7 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
- data/spec/unit/knife/cookbook_show_spec.rb +1 -1
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
- data/spec/unit/knife/environment_from_file_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +27 -17
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife/supermarket_install_spec.rb +1 -1
- data/spec/unit/mixin/path_sanity_spec.rb +3 -3
- data/spec/unit/mixin/shell_out_spec.rb +2 -3
- data/spec/unit/mixin/template_spec.rb +4 -4
- data/spec/unit/mixin/user_context_spec.rb +3 -3
- data/spec/unit/node_map_spec.rb +12 -12
- data/spec/unit/platform/query_helpers_spec.rb +9 -9
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/openbsd_spec.rb +1 -1
- data/spec/unit/provider/package/smartos_spec.rb +1 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +2 -2
- data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
- data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
- data/spec/unit/provider/subversion_spec.rb +3 -3
- data/spec/unit/provider/systemd_unit_spec.rb +53 -4
- data/spec/unit/provider/user/dscl_spec.rb +1 -1
- data/spec/unit/provider_resolver_spec.rb +41 -61
- data/spec/unit/resource/chef_sleep_spec.rb +30 -0
- data/spec/unit/resource/cookbook_file_spec.rb +3 -3
- data/spec/unit/resource/remote_file_spec.rb +3 -3
- data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
- data/spec/unit/role_spec.rb +2 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/win32/error_spec.rb +1 -1
- data/spec/unit/win32/link_spec.rb +1 -1
- data/spec/unit/win32/security_spec.rb +1 -1
- data/spec/unit/windows_service_spec.rb +1 -1
- data/tasks/docs.rb +10 -2
- data/tasks/rspec.rb +8 -6
- metadata +33 -9
- data/lib/chef/mixin/train_helpers.rb +0 -60
- data/spec/unit/mash_spec.rb +0 -51
data/lib/chef/config.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Author:: AJ Christensen (<aj@chef.io>)
|
5
5
|
# Author:: Mark Mzyk (<mmzyk@chef.io>)
|
6
6
|
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
|
7
|
-
# Copyright:: Copyright 2008-
|
7
|
+
# Copyright:: Copyright 2008-2019, Chef Software Inc.
|
8
8
|
# License:: Apache License, Version 2.0
|
9
9
|
#
|
10
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -28,6 +28,7 @@ require "chef-config/logger"
|
|
28
28
|
ChefConfig.logger = Chef::Log
|
29
29
|
|
30
30
|
require "chef-config/config"
|
31
|
+
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
31
32
|
require_relative "platform/query_helpers"
|
32
33
|
|
33
34
|
# Ohai::Config defines its own log_level and log_location. When loaded, it will
|
@@ -55,7 +56,7 @@ class Chef
|
|
55
56
|
|
56
57
|
default :event_loggers do
|
57
58
|
evt_loggers = []
|
58
|
-
if
|
59
|
+
if ChefUtils.windows? && !Chef::Platform.windows_nano_server?
|
59
60
|
evt_loggers << :win_evt
|
60
61
|
end
|
61
62
|
evt_loggers
|
@@ -24,11 +24,9 @@ class Chef
|
|
24
24
|
attr_reader :ignores
|
25
25
|
|
26
26
|
def initialize(ignore_file_or_repo)
|
27
|
-
# Check the 'ignore_file_or_repo' path first and then look in the parent
|
27
|
+
# Check the 'ignore_file_or_repo' path first and then look in the parent directories till root
|
28
28
|
# to handle both the chef repo cookbook layout and a standalone cookbook
|
29
29
|
@ignore_file = find_ignore_file(ignore_file_or_repo)
|
30
|
-
@ignore_file = find_ignore_file(File.dirname(ignore_file_or_repo)) unless readable_file_or_symlink?(@ignore_file)
|
31
|
-
|
32
30
|
@ignores = parse_ignore_file
|
33
31
|
end
|
34
32
|
|
@@ -50,27 +48,34 @@ class Chef
|
|
50
48
|
|
51
49
|
def parse_ignore_file
|
52
50
|
ignore_globs = []
|
53
|
-
if readable_file_or_symlink?(@ignore_file)
|
51
|
+
if @ignore_file && readable_file_or_symlink?(@ignore_file)
|
54
52
|
File.foreach(@ignore_file) do |line|
|
55
53
|
ignore_globs << line.strip unless line =~ COMMENTS_AND_WHITESPACE
|
56
54
|
end
|
57
55
|
else
|
58
|
-
Chef::Log.
|
56
|
+
Chef::Log.debug("No chefignore file found. No files will be ignored!")
|
59
57
|
end
|
60
58
|
ignore_globs
|
61
59
|
end
|
62
60
|
|
61
|
+
# Lookup of chefignore file till the root dir of the provided path.
|
62
|
+
# If file refer then lookup the parent dir till the root.
|
63
|
+
# eg. path: /var/.chef/cookbook_name
|
64
|
+
# Lookup at '/var/.chef/cookbook_name/chefignore', '/var/.chef/chefignore' '/var/chefignore' and '/chefignore' until exist
|
63
65
|
def find_ignore_file(path)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
Pathname.new(path).ascend do |dir|
|
67
|
+
next unless dir.directory?
|
68
|
+
|
69
|
+
file = dir.join("chefignore")
|
70
|
+
return file.expand_path.to_s if file.exist?
|
68
71
|
end
|
72
|
+
|
73
|
+
nil
|
69
74
|
end
|
70
75
|
|
71
76
|
def readable_file_or_symlink?(path)
|
72
|
-
File.exist?(
|
73
|
-
(File.file?(
|
77
|
+
File.exist?(path) && File.readable?(path) &&
|
78
|
+
(File.file?(path) || File.symlink?(path))
|
74
79
|
end
|
75
80
|
end
|
76
81
|
end
|
@@ -84,11 +84,13 @@ class Chef
|
|
84
84
|
# If no +cookbook_path+ is given, +Chef::Config.cookbook_path+ is used.
|
85
85
|
def self.for_cookbook(cookbook_name, cookbook_path = nil)
|
86
86
|
cookbook_path ||= Chef::Config.cookbook_path
|
87
|
-
|
88
|
-
|
87
|
+
|
88
|
+
Array(cookbook_path).each do |entry|
|
89
|
+
path = File.expand_path(File.join(entry, cookbook_name.to_s))
|
90
|
+
return new(path) if Dir.exist?(path)
|
89
91
|
end
|
90
92
|
|
91
|
-
|
93
|
+
raise ArgumentError, "Cannot find cookbook #{cookbook_name} unless Chef::Config.cookbook_path is set or an explicit cookbook path is given"
|
92
94
|
end
|
93
95
|
|
94
96
|
# Create a new SyntaxCheck object
|
data/lib/chef/cookbook_loader.rb
CHANGED
@@ -49,8 +49,8 @@ class Chef
|
|
49
49
|
|
50
50
|
# @param repo_paths [Array<String>] the array of repo paths containing cookbook dirs
|
51
51
|
def initialize(*repo_paths)
|
52
|
-
@repo_paths = repo_paths.flatten.map { |p| File.expand_path(p) }
|
53
|
-
raise ArgumentError, "You must specify at least one cookbook repo path" if repo_paths.empty?
|
52
|
+
@repo_paths = repo_paths.flatten.compact.map { |p| File.expand_path(p) }
|
53
|
+
raise ArgumentError, "You must specify at least one cookbook repo path" if @repo_paths.empty?
|
54
54
|
end
|
55
55
|
|
56
56
|
# The primary function of this class is to build this Mash mapping cookbook names as a string to
|
@@ -171,7 +171,7 @@ class Chef
|
|
171
171
|
begin
|
172
172
|
mash = Mash.new
|
173
173
|
all_directories_in_repo_paths.each do |cookbook_path|
|
174
|
-
loader = Cookbook::CookbookVersionLoader.new(cookbook_path, chefignore(
|
174
|
+
loader = Cookbook::CookbookVersionLoader.new(cookbook_path, chefignore(cookbook_path))
|
175
175
|
cookbook_name = loader.cookbook_name
|
176
176
|
if mash.key?(cookbook_name)
|
177
177
|
raise Chef::Exceptions::CookbookMergingError, "Cookbook merging is no longer supported, the cookbook named #{cookbook_name} can only appear once in the cookbook_path"
|
@@ -139,7 +139,7 @@ class Chef
|
|
139
139
|
|
140
140
|
def validate_cookbooks
|
141
141
|
cookbooks.each do |cb|
|
142
|
-
syntax_checker = Chef::Cookbook::SyntaxCheck.
|
142
|
+
syntax_checker = Chef::Cookbook::SyntaxCheck.new(cb.root_dir)
|
143
143
|
Chef::Log.info("Validating ruby files")
|
144
144
|
exit(1) unless syntax_checker.validate_ruby_files
|
145
145
|
Chef::Log.info("Validating templates")
|
data/lib/chef/data_collector.rb
CHANGED
@@ -64,8 +64,8 @@ class Chef
|
|
64
64
|
# @param events [Chef::EventDispatch::Dispatcher] the event dispatcher
|
65
65
|
def initialize(events)
|
66
66
|
@events = events
|
67
|
-
@expanded_run_list
|
68
|
-
@deprecations
|
67
|
+
@expanded_run_list = {}
|
68
|
+
@deprecations = Set.new
|
69
69
|
end
|
70
70
|
|
71
71
|
# Hook to grab the run_status. We also make the decision to run or not run here (our
|
@@ -57,6 +57,7 @@ class Chef
|
|
57
57
|
"resources" => all_action_records(action_collection),
|
58
58
|
"run_id" => run_status&.run_id,
|
59
59
|
"run_list" => node&.run_list&.for_json || [],
|
60
|
+
"cookbooks" => ( node && node["cookbooks"] ) || {},
|
60
61
|
"policy_name" => node&.policy_name,
|
61
62
|
"policy_group" => node&.policy_group,
|
62
63
|
"start_time" => run_status.start_time.utc.iso8601,
|
data/lib/chef/deprecated.rb
CHANGED
data/lib/chef/dsl/core.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
3
|
# Author:: Christopher Walters (<cw@chef.io>)
|
4
|
-
# Copyright:: Copyright 2008-
|
4
|
+
# Copyright:: Copyright 2008-2019, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,13 +16,15 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
+
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
20
|
+
|
19
21
|
class Chef
|
20
22
|
module DSL
|
21
|
-
|
22
23
|
# == Chef::DSL::PlatformIntrospection
|
23
24
|
# Provides the DSL for platform-dependent switch logic, such as
|
24
25
|
# #value_for_platform.
|
25
26
|
module PlatformIntrospection
|
27
|
+
include ChefUtils
|
26
28
|
|
27
29
|
# Implementation class for determining platform dependent values
|
28
30
|
class PlatformDependentValue
|
@@ -245,27 +247,16 @@ class Chef
|
|
245
247
|
end
|
246
248
|
end
|
247
249
|
|
248
|
-
# Shamelessly stolen from https://github.com/sethvargo/chef-sugar/blob/master/lib/chef/sugar/docker.rb
|
249
|
-
# Given a node object, returns whether the node is a docker container.
|
250
|
-
#
|
251
|
-
# === Parameters
|
252
|
-
# node:: [Chef::Node] The node to check.
|
253
|
-
#
|
254
|
-
# === Returns
|
255
|
-
# true:: if the current node is a docker container
|
256
|
-
# false:: if the current node is not a docker container
|
257
|
-
def docker?(node = run_context.nil? ? nil : run_context.node)
|
258
|
-
# Using "File.exist?('/.dockerinit') || File.exist?('/.dockerenv')" makes Travis sad,
|
259
|
-
# and that makes us sad too.
|
260
|
-
!!(node && node[:virtualization] && node[:virtualization][:systems] &&
|
261
|
-
node[:virtualization][:systems][:docker] && node[:virtualization][:systems][:docker] == "guest")
|
262
|
-
end
|
263
|
-
|
264
250
|
# a simple helper to determine if we're on a windows release pre-2012 / 8
|
265
251
|
# @return [Boolean] Is the system older than Windows 8 / 2012
|
266
252
|
def older_than_win_2012_or_8?(node = run_context.nil? ? nil : run_context.node)
|
267
253
|
node["platform_version"].to_f < 6.2
|
268
254
|
end
|
255
|
+
|
256
|
+
# ^^^^^^ NOTE: PLEASE DO NOT CONTINUE TO ADD THESE KINDS OF PLATFORM_VERSION APIS WITHOUT ^^^^^^^
|
257
|
+
# ^^^^^^ GOING THROUGH THE DESIGN REVIEW PROCESS AND ADDRESS THE EXISTING CHEF-SUGAR ONES ^^^^^^^
|
258
|
+
# ^^^^^^ DO "THE HARD RIGHT THING" AND ADDRESS THE BROADER PROBLEM AND FIX IT ALL. ^^^^^^^
|
259
|
+
|
269
260
|
end
|
270
261
|
end
|
271
262
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Lamont Granquist (<lamont@chef.io>)
|
3
|
-
# Copyright:: Copyright 2013-
|
3
|
+
# Copyright:: Copyright 2013-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
require_relative "deploy/cp"
|
20
20
|
require_relative "deploy/mv_unix"
|
21
|
-
if
|
21
|
+
if ChefUtils.windows?
|
22
22
|
require_relative "deploy/mv_windows"
|
23
23
|
end
|
24
24
|
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
class Deploy
|
28
28
|
def self.strategy(atomic_update)
|
29
29
|
if atomic_update
|
30
|
-
|
30
|
+
ChefUtils.windows? ? MvWindows.new : MvUnix.new
|
31
31
|
else
|
32
32
|
Cp.new
|
33
33
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Lamont Granquist (<lamont@chef.io>)
|
3
|
-
# Copyright:: Copyright 2013-
|
3
|
+
# Copyright:: Copyright 2013-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -22,7 +22,7 @@
|
|
22
22
|
#
|
23
23
|
|
24
24
|
require_relative "../../platform/query_helpers"
|
25
|
-
if
|
25
|
+
if ChefUtils.windows?
|
26
26
|
require_relative "../../win32/security"
|
27
27
|
end
|
28
28
|
|
@@ -67,7 +67,7 @@ class Chef
|
|
67
67
|
basename = ::File.basename(@new_resource.path, tempfile_extension)
|
68
68
|
# the leading "[.]chef-" here should be considered a public API and should not be changed
|
69
69
|
basename.insert 0, "chef-"
|
70
|
-
basename.insert 0, "." unless
|
70
|
+
basename.insert 0, "." unless ChefUtils.windows? # dotfile if we're not on windows
|
71
71
|
basename.scrub
|
72
72
|
end
|
73
73
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
3
3
|
# Author:: Tyler Cloke (<tyler@chef.io>)
|
4
|
-
# Copyright:: Copyright 2012-
|
4
|
+
# Copyright:: Copyright 2012-2019, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -52,7 +52,7 @@ class Chef
|
|
52
52
|
error_description.section("Template Context:", "#{exception.source_location}\n#{exception.source_listing}")
|
53
53
|
end
|
54
54
|
|
55
|
-
if
|
55
|
+
if ChefUtils.windows?
|
56
56
|
require_relative "../../win32/security"
|
57
57
|
|
58
58
|
unless Chef::ReservedNames::Win32::Security.has_admin_privileges?
|
data/lib/chef/http.rb
CHANGED
data/lib/chef/knife.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
3
|
# Author:: Christopher Brown (<cb@chef.io>)
|
4
|
-
# Copyright:: Copyright 2009-
|
4
|
+
# Copyright:: Copyright 2009-2019, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -20,6 +20,7 @@
|
|
20
20
|
require "forwardable" unless defined?(Forwardable)
|
21
21
|
require_relative "version"
|
22
22
|
require "mixlib/cli" unless defined?(Mixlib::CLI)
|
23
|
+
require "chef-utils/dsl/path_sanity" unless defined?(ChefUtils::DSL::PathSanity)
|
23
24
|
require_relative "workstation_config_loader"
|
24
25
|
require_relative "mixin/convert_to_class_name"
|
25
26
|
require_relative "mixin/path_sanity"
|
@@ -39,7 +40,7 @@ class Chef
|
|
39
40
|
Chef::HTTP::HTTPRequest.user_agent = "#{Chef::Dist::PRODUCT} Knife#{Chef::HTTP::HTTPRequest::UA_COMMON}"
|
40
41
|
|
41
42
|
include Mixlib::CLI
|
42
|
-
include
|
43
|
+
include ChefUtils::DSL::PathSanity
|
43
44
|
extend Chef::Mixin::ConvertToClassName
|
44
45
|
extend Forwardable
|
45
46
|
|
@@ -479,7 +480,7 @@ class Chef
|
|
479
480
|
unless respond_to?(:run)
|
480
481
|
ui.error "You need to add a #run method to your knife command before you can use it"
|
481
482
|
end
|
482
|
-
enforce_path_sanity
|
483
|
+
ENV["PATH"] = sanitized_path if Chef::Config[:enforce_path_sanity]
|
483
484
|
maybe_setup_fips
|
484
485
|
Chef::LocalMode.with_server_connectivity do
|
485
486
|
run
|
@@ -47,9 +47,10 @@ class Chef
|
|
47
47
|
if wcl.config_location
|
48
48
|
loading_from("configuration", wcl.config_location)
|
49
49
|
end
|
50
|
+
|
50
51
|
if Chef::Config[:config_d_dir]
|
51
52
|
wcl.find_dot_d(Chef::Config[:config_d_dir]).each do |path|
|
52
|
-
loading_from(".d/ configuration",
|
53
|
+
loading_from(".d/ configuration", path)
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
data/lib/chef/knife/configure.rb
CHANGED
@@ -120,7 +120,7 @@ class Chef
|
|
120
120
|
@admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", default: "#{Chef::Dist::SERVER_CONF_DIR}/admin.pem")
|
121
121
|
@admin_client_key = File.expand_path(@admin_client_key)
|
122
122
|
else
|
123
|
-
@new_client_name
|
123
|
+
@new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", default: Etc.getlogin)
|
124
124
|
end
|
125
125
|
|
126
126
|
@new_client_key = config[:client_key] || File.join(chef_config_path, "#{@new_client_name}.pem")
|
@@ -31,6 +31,12 @@ class Chef
|
|
31
31
|
banner "knife cookbook metadata from file FILE (options)"
|
32
32
|
|
33
33
|
def run
|
34
|
+
if @name_args.length < 1
|
35
|
+
show_usage
|
36
|
+
ui.fatal("You must specify the FILE.")
|
37
|
+
exit(1)
|
38
|
+
end
|
39
|
+
|
34
40
|
file = @name_args[0]
|
35
41
|
cookbook = File.basename(File.dirname(file))
|
36
42
|
|
@@ -191,7 +191,7 @@ class Chef
|
|
191
191
|
data =
|
192
192
|
if data.is_a?(Array)
|
193
193
|
data[attr.to_i]
|
194
|
-
elsif data.respond_to?(:[], false) && data.key?(attr)
|
194
|
+
elsif data.respond_to?(:[], false) && data.respond_to?(:key?) && data.key?(attr)
|
195
195
|
data[attr]
|
196
196
|
elsif data.respond_to?(attr.to_sym, false)
|
197
197
|
# handles -a chef_environment and other things that hang of the node and aren't really attributes
|
@@ -112,7 +112,7 @@ class Chef
|
|
112
112
|
|
113
113
|
if node["ohai_time"]
|
114
114
|
hours, minutes, seconds = time_difference_in_hms(node["ohai_time"])
|
115
|
-
hours_text
|
115
|
+
hours_text = "#{hours} hour#{hours == 1 ? " " : "s"}"
|
116
116
|
minutes_text = "#{minutes} minute#{minutes == 1 ? " " : "s"}"
|
117
117
|
seconds_text = "#{seconds} second#{seconds == 1 ? " " : "s"}"
|
118
118
|
if hours > 24
|
data/lib/chef/knife/ssh.rb
CHANGED
@@ -593,6 +593,12 @@ class Chef
|
|
593
593
|
def run
|
594
594
|
@longest = 0
|
595
595
|
|
596
|
+
if @name_args.length < 1
|
597
|
+
show_usage
|
598
|
+
ui.fatal("You must specify the SEARCH QUERY.")
|
599
|
+
exit(1)
|
600
|
+
end
|
601
|
+
|
596
602
|
configure_user
|
597
603
|
configure_password
|
598
604
|
@password = config[:ssh_password] if config[:ssh_password]
|
data/lib/chef/local_mode.rb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
18
|
require_relative "config"
|
19
|
-
require_relative "monkey_patches/webrick-utils" if
|
19
|
+
require_relative "monkey_patches/webrick-utils" if ChefUtils.windows?
|
20
20
|
require_relative "dist"
|
21
21
|
|
22
22
|
class Chef
|