chef 15.10.12-universal-mingw32 → 15.14.0-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +10 -10
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/chef-universal-mingw32.gemspec +2 -2
- data/chef.gemspec +3 -3
- data/distro/powershell/chef/chef.psm1 +3 -3
- data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
- data/lib/chef/api_client/registration.rb +2 -2
- data/lib/chef/application/apply.rb +2 -2
- data/lib/chef/application/exit_code.rb +2 -2
- data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -3
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +3 -3
- data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
- data/lib/chef/cookbook_version.rb +4 -4
- data/lib/chef/data_bag.rb +2 -2
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/deprecated.rb +13 -1
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +3 -1
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/exceptions.rb +3 -0
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +7 -7
- data/lib/chef/http.rb +2 -1
- data/lib/chef/knife.rb +26 -20
- data/lib/chef/knife/bootstrap.rb +30 -31
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +12 -8
- data/lib/chef/knife/bootstrap/client_builder.rb +23 -19
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
- data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
- data/lib/chef/knife/cookbook_download.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_show.rb +1 -1
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +18 -3
- data/lib/chef/knife/exec.rb +2 -2
- data/lib/chef/knife/ssh.rb +21 -2
- data/lib/chef/log.rb +1 -1
- data/lib/chef/mixin/create_path.rb +8 -8
- data/lib/chef/mixin/openssl_helper.rb +26 -3
- data/lib/chef/mixin/template.rb +1 -0
- data/lib/chef/node/mixin/deep_merge_cache.rb +7 -7
- data/lib/chef/node_map.rb +5 -2
- data/lib/chef/provider/mount/solaris.rb +0 -1
- data/lib/chef/provider/package/cab.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +4 -3
- data/lib/chef/provider/package/msu.rb +1 -0
- data/lib/chef/provider/package/powershell.rb +5 -1
- data/lib/chef/provider/package/snap.rb +96 -27
- data/lib/chef/provider/package/zypper.rb +0 -1
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/debian.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/simple.rb +3 -3
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/windows_task.rb +1 -1
- data/lib/chef/provider/yum_repository.rb +1 -1
- data/lib/chef/provider/zypper_repository.rb +31 -11
- data/lib/chef/resource.rb +2 -0
- data/lib/chef/resource/archive_file.rb +28 -8
- data/lib/chef/resource/build_essential.rb +1 -1
- data/lib/chef/resource/cron_access.rb +13 -5
- data/lib/chef/resource/cron_d.rb +1 -1
- data/lib/chef/resource/hostname.rb +19 -18
- data/lib/chef/resource/launchd.rb +4 -4
- data/lib/chef/resource/lwrp_base.rb +7 -0
- data/lib/chef/resource/macos_userdefaults.rb +3 -3
- data/lib/chef/resource/msu_package.rb +5 -0
- data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
- data/lib/chef/resource/sudo.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +6 -2
- data/lib/chef/resource/windows_firewall_rule.rb +8 -4
- data/lib/chef/resource/windows_font.rb +2 -1
- data/lib/chef/resource/windows_share.rb +4 -4
- data/lib/chef/resource/windows_task.rb +13 -13
- data/lib/chef/resource_inspector.rb +4 -3
- data/lib/chef/role.rb +2 -2
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/shell/shell_session.rb +2 -0
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +3 -3
- data/lib/chef/util/powershell/cmdlet.rb +1 -1
- data/lib/chef/version.rb +2 -2
- data/lib/chef/win32/api/command_line_helper.rb +89 -0
- data/lib/chef/win32/api/file.rb +18 -18
- data/lib/chef/win32/file.rb +3 -3
- data/lib/chef/win32/process.rb +2 -2
- data/spec/functional/knife/ssh_spec.rb +4 -4
- data/spec/functional/resource/aix_service_spec.rb +0 -1
- data/spec/functional/resource/aixinit_service_spec.rb +7 -8
- data/spec/functional/resource/apt_package_spec.rb +0 -1
- data/spec/functional/resource/bff_spec.rb +2 -2
- data/spec/functional/resource/chocolatey_package_spec.rb +29 -0
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +0 -1
- data/spec/functional/resource/dsc_resource_spec.rb +1 -1
- data/spec/functional/resource/insserv_spec.rb +4 -5
- data/spec/functional/resource/link_spec.rb +17 -17
- data/spec/functional/resource/msu_package_spec.rb +5 -2
- data/spec/functional/resource/rpm_spec.rb +2 -2
- data/spec/functional/resource/user/dscl_spec.rb +2 -2
- data/spec/functional/resource/user/mac_user_spec.rb +2 -2
- data/spec/functional/resource/windows_certificate_spec.rb +3 -3
- data/spec/functional/resource/windows_font_spec.rb +49 -0
- data/spec/functional/resource/windows_task_spec.rb +8 -8
- data/spec/functional/run_lock_spec.rb +2 -1
- data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/integration/recipes/accumulator_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
- data/spec/integration/recipes/lwrp_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/notifying_block_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
- data/spec/integration/recipes/resource_load_spec.rb +1 -0
- data/spec/integration/recipes/unified_mode_spec.rb +1 -1
- data/spec/scripts/ssl-serve.rb +1 -1
- data/spec/spec_helper.rb +26 -19
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/platform_helpers.rb +12 -42
- data/spec/support/platforms/win32/spec_service.rb +1 -1
- data/spec/support/shared/functional/directory_resource.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +3 -3
- data/spec/support/shared/functional/win32_service.rb +1 -1
- data/spec/support/shared/functional/windows_script.rb +3 -3
- data/spec/support/shared/integration/knife_support.rb +2 -5
- data/spec/unit/application_spec.rb +7 -0
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
- data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
- data/spec/unit/data_bag_spec.rb +1 -1
- data/spec/unit/data_collector_spec.rb +1 -1
- data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
- data/spec/unit/environment_spec.rb +7 -7
- data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
- data/spec/unit/file_access_control_spec.rb +1 -1
- data/spec/unit/json_compat_spec.rb +1 -1
- data/spec/unit/knife/bootstrap_spec.rb +26 -29
- data/spec/unit/knife/cookbook_download_spec.rb +4 -4
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
- data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +6 -0
- data/spec/unit/knife/role_env_run_list_add_spec.rb +6 -6
- data/spec/unit/knife/role_env_run_list_clear_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_remove_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_replace_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_set_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_add_spec.rb +6 -6
- data/spec/unit/knife/role_run_list_clear_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_remove_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_replace_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_set_spec.rb +4 -4
- data/spec/unit/knife/ssh_spec.rb +2 -2
- data/spec/unit/knife/supermarket_share_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +4 -4
- data/spec/unit/mixin/securable_spec.rb +0 -1
- data/spec/unit/mixin/user_context_spec.rb +1 -9
- data/spec/unit/property_spec.rb +6 -6
- data/spec/unit/provider/apt_repository_spec.rb +2 -2
- data/spec/unit/provider/git_spec.rb +3 -3
- data/spec/unit/provider/osx_profile_spec.rb +2 -2
- data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
- data/spec/unit/provider/package/msu_spec.rb +3 -3
- data/spec/unit/provider/package/powershell_spec.rb +95 -86
- data/spec/unit/provider/package/rubygems_spec.rb +5 -10
- data/spec/unit/provider/package/snap_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +30 -53
- data/spec/unit/provider/service/arch_service_spec.rb +3 -2
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/gentoo_service_spec.rb +8 -8
- data/spec/unit/provider/service/macosx_spec.rb +3 -3
- data/spec/unit/provider/service/redhat_spec.rb +2 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
- data/spec/unit/provider/service/windows_spec.rb +2 -6
- data/spec/unit/provider/systemd_unit_spec.rb +28 -24
- data/spec/unit/provider/zypper_repository_spec.rb +75 -25
- data/spec/unit/provider_resolver_spec.rb +9 -9
- data/spec/unit/provider_spec.rb +1 -0
- data/spec/unit/resource/archive_file_spec.rb +11 -2
- data/spec/unit/resource/msu_package_spec.rb +4 -0
- data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
- data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
- data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
- data/spec/unit/resource/windows_package_spec.rb +1 -0
- data/spec/unit/resource/windows_task_spec.rb +1 -1
- data/spec/unit/resource/windows_uac_spec.rb +2 -2
- data/spec/unit/resource/yum_repository_spec.rb +21 -21
- data/spec/unit/resource_reporter_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +1 -1
- data/spec/unit/role_spec.rb +11 -11
- data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
- data/spec/unit/run_context_spec.rb +1 -1
- data/spec/unit/run_lock_spec.rb +1 -1
- data/spec/unit/scan_access_control_spec.rb +1 -1
- data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
- data/spec/unit/win32/security_spec.rb +4 -3
- data/tasks/rspec.rb +5 -13
- metadata +32 -18
data/lib/chef/resource.rb
CHANGED
@@ -613,6 +613,7 @@ class Chef
|
|
613
613
|
# Do NOT use this. It may be removed. It is for internal purposes only.
|
614
614
|
# @api private
|
615
615
|
attr_reader :resource_initializing
|
616
|
+
|
616
617
|
def resource_initializing=(value)
|
617
618
|
if value
|
618
619
|
@resource_initializing = true
|
@@ -863,6 +864,7 @@ class Chef
|
|
863
864
|
# have.
|
864
865
|
#
|
865
866
|
attr_writer :allowed_actions
|
867
|
+
|
866
868
|
def allowed_actions(value = NOT_PASSED)
|
867
869
|
if value != NOT_PASSED
|
868
870
|
self.allowed_actions = value
|
@@ -19,6 +19,7 @@
|
|
19
19
|
#
|
20
20
|
|
21
21
|
require_relative "../resource"
|
22
|
+
require "fileutils" unless defined?(FileUtils)
|
22
23
|
|
23
24
|
class Chef
|
24
25
|
class Resource
|
@@ -38,6 +39,18 @@ class Chef
|
|
38
39
|
destination '/srv/files'
|
39
40
|
end
|
40
41
|
```
|
42
|
+
|
43
|
+
**Set specific permissions on the extracted files**:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
archive_file 'Precompiled.zip' do
|
47
|
+
owner 'tsmith'
|
48
|
+
group 'staff'
|
49
|
+
mode '700'
|
50
|
+
path '/tmp/Precompiled.zip'
|
51
|
+
destination '/srv/files'
|
52
|
+
end
|
53
|
+
```
|
41
54
|
DOC
|
42
55
|
|
43
56
|
property :path, String,
|
@@ -52,7 +65,7 @@ class Chef
|
|
52
65
|
description: "The group of the extracted files."
|
53
66
|
|
54
67
|
property :mode, [String, Integer],
|
55
|
-
description: "The mode of the extracted files.",
|
68
|
+
description: "The mode of the extracted files. Integer values are deprecated as octal values (ex. 0755) would not be interpreted correctly.",
|
56
69
|
default: "755"
|
57
70
|
|
58
71
|
property :destination, String,
|
@@ -71,11 +84,11 @@ class Chef
|
|
71
84
|
alias_method :extract_options, :options
|
72
85
|
alias_method :extract_to, :destination
|
73
86
|
|
74
|
-
require "fileutils" unless defined?(FileUtils)
|
75
|
-
|
76
87
|
action :extract do
|
77
88
|
description "Extract and archive file."
|
78
89
|
|
90
|
+
require_libarchive
|
91
|
+
|
79
92
|
unless ::File.exist?(new_resource.path)
|
80
93
|
raise Errno::ENOENT, "No archive found at #{new_resource.path}! Cannot continue."
|
81
94
|
end
|
@@ -84,7 +97,8 @@ class Chef
|
|
84
97
|
Chef::Log.trace("File or directory does not exist at destination path: #{new_resource.destination}")
|
85
98
|
|
86
99
|
converge_by("create directory #{new_resource.destination}") do
|
87
|
-
|
100
|
+
# @todo when we remove the ability for mode to be an int we can remove the .to_s below
|
101
|
+
FileUtils.mkdir_p(new_resource.destination, mode: new_resource.mode.to_s.to_i(8))
|
88
102
|
end
|
89
103
|
|
90
104
|
extract(new_resource.path, new_resource.destination, Array(new_resource.options))
|
@@ -112,6 +126,16 @@ class Chef
|
|
112
126
|
end
|
113
127
|
|
114
128
|
action_class do
|
129
|
+
def require_libarchive
|
130
|
+
require "ffi-libarchive"
|
131
|
+
end
|
132
|
+
|
133
|
+
def define_resource_requirements
|
134
|
+
if new_resource.mode.is_a?(Integer)
|
135
|
+
Chef.deprecated(:archive_file_integer_file_mode, "The mode property should be passed to archive_file resources as a String and not an Integer to ensure the value is properly interpreted.")
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
115
139
|
# This can't be a constant since we might not have required 'ffi-libarchive' yet.
|
116
140
|
def extract_option_map
|
117
141
|
{
|
@@ -135,8 +159,6 @@ class Chef
|
|
135
159
|
#
|
136
160
|
# @return [Boolean]
|
137
161
|
def archive_differs_from_disk?(src, dest)
|
138
|
-
require "ffi-libarchive"
|
139
|
-
|
140
162
|
modified = false
|
141
163
|
Dir.chdir(dest) do
|
142
164
|
archive = Archive::Reader.open_filename(src)
|
@@ -163,8 +185,6 @@ class Chef
|
|
163
185
|
#
|
164
186
|
# @return [void]
|
165
187
|
def extract(src, dest, options = [])
|
166
|
-
require "ffi-libarchive"
|
167
|
-
|
168
188
|
converge_by("extract #{src} to #{dest}") do
|
169
189
|
flags = [options].flatten.map { |option| extract_option_map[option] }.compact.reduce(:|)
|
170
190
|
|
@@ -60,7 +60,7 @@ class Chef
|
|
60
60
|
when fedora_derived?
|
61
61
|
package %w{ autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch }
|
62
62
|
|
63
|
-
|
63
|
+
# Ensure GCC 4 is available on older pre-6 EL
|
64
64
|
package %w{ gcc44 gcc44-c++ } if platform_family?("rhel") && node["platform_version"].to_i < 6
|
65
65
|
when freebsd?
|
66
66
|
package "devel/gmake"
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
provides(:cron_manage) # legacy name @todo in Chef 15 we should { true } this so it wins over the cookbook
|
28
28
|
|
29
29
|
introduced "14.4"
|
30
|
-
description "Use the cron_access resource to manage
|
30
|
+
description "Use the **cron_access** resource to manage cron's cron.allow and cron.deny files. Note: This resource previously shipped in the `cron` cookbook as `cron_manage`, which it can still be used as for backwards compatibility with existing Chef Infra Client releases."
|
31
31
|
examples <<~DOC
|
32
32
|
Add the mike user to cron.allow
|
33
33
|
```ruby
|
@@ -54,12 +54,19 @@ class Chef
|
|
54
54
|
description: "An optional property to set the user name if it differs from the resource block's name.",
|
55
55
|
name_property: true
|
56
56
|
|
57
|
+
CRON_PATHS = {
|
58
|
+
"aix" => "/var/adm/cron",
|
59
|
+
"solaris" => "/etc/cron.d",
|
60
|
+
"default" => "/etc",
|
61
|
+
}.freeze
|
62
|
+
|
57
63
|
action :allow do
|
58
64
|
description "Add the user to the cron.allow file."
|
65
|
+
allow_path = ::File.join(value_for_platform_family(CRON_PATHS), "cron.allow")
|
59
66
|
|
60
67
|
with_run_context :root do
|
61
|
-
edit_resource(:template,
|
62
|
-
source ::File.expand_path("
|
68
|
+
edit_resource(:template, allow_path) do |new_resource|
|
69
|
+
source ::File.expand_path("support/cron_access.erb", __dir__)
|
63
70
|
local true
|
64
71
|
mode "0600"
|
65
72
|
variables["users"] ||= []
|
@@ -72,10 +79,11 @@ class Chef
|
|
72
79
|
|
73
80
|
action :deny do
|
74
81
|
description "Add the user to the cron.deny file."
|
82
|
+
deny_path = ::File.join(value_for_platform_family(CRON_PATHS), "cron.deny")
|
75
83
|
|
76
84
|
with_run_context :root do
|
77
|
-
edit_resource(:template,
|
78
|
-
source ::File.expand_path("
|
85
|
+
edit_resource(:template, deny_path) do |new_resource|
|
86
|
+
source ::File.expand_path("support/cron_access.erb", __dir__)
|
79
87
|
local true
|
80
88
|
mode "0600"
|
81
89
|
variables["users"] ||= []
|
data/lib/chef/resource/cron_d.rb
CHANGED
@@ -289,7 +289,7 @@ class Chef
|
|
289
289
|
|
290
290
|
# @todo this is Chef 12 era cleanup. Someday we should remove it all
|
291
291
|
template "/etc/cron.d/#{sanitized_name}" do
|
292
|
-
source ::File.expand_path("
|
292
|
+
source ::File.expand_path("support/cron.d.erb", __dir__)
|
293
293
|
local true
|
294
294
|
mode new_resource.mode
|
295
295
|
variables(
|
@@ -13,6 +13,7 @@
|
|
13
13
|
#
|
14
14
|
|
15
15
|
require_relative "../resource"
|
16
|
+
require_relative "../dist"
|
16
17
|
|
17
18
|
class Chef
|
18
19
|
class Resource
|
@@ -66,8 +67,7 @@ class Chef
|
|
66
67
|
def updated_ec2_config_xml
|
67
68
|
begin
|
68
69
|
require "rexml/document" unless defined?(REXML::Document)
|
69
|
-
|
70
|
-
config = REXML::Document.new(::File.read(config_file))
|
70
|
+
config = REXML::Document.new(::File.read(WINDOWS_EC2_CONFIG))
|
71
71
|
# find an element named State with a sibling element whose value is Ec2SetComputerName
|
72
72
|
REXML::XPath.each(config, "//Plugin/State[../Name/text() = 'Ec2SetComputerName']") do |element|
|
73
73
|
element.text = "Disabled"
|
@@ -219,35 +219,36 @@ class Chef
|
|
219
219
|
end
|
220
220
|
|
221
221
|
else # windows
|
222
|
+
WINDOWS_EC2_CONFIG = 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml'.freeze
|
223
|
+
|
222
224
|
raise "Windows hostnames cannot contain a period." if new_resource.hostname.match?(/\./)
|
223
225
|
|
224
226
|
# suppress EC2 config service from setting our hostname
|
225
|
-
if ::File.exist?(
|
227
|
+
if ::File.exist?(WINDOWS_EC2_CONFIG)
|
226
228
|
xml_contents = updated_ec2_config_xml
|
227
229
|
if xml_contents.empty?
|
228
230
|
Chef::Log.warn('Unable to properly parse and update C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml contents. Skipping file update.')
|
229
231
|
else
|
230
|
-
|
232
|
+
file WINDOWS_EC2_CONFIG do
|
231
233
|
content xml_contents
|
232
234
|
end
|
233
235
|
end
|
234
236
|
end
|
235
237
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
not_if { Socket.gethostbyname(Socket.gethostname).first == new_resource.hostname }
|
244
|
-
end
|
238
|
+
unless Socket.gethostbyname(Socket.gethostname).first == new_resource.hostname
|
239
|
+
converge_by "set hostname to #{new_resource.hostname}" do
|
240
|
+
powershell_out! <<~EOH
|
241
|
+
$sysInfo = Get-WmiObject -Class Win32_ComputerSystem
|
242
|
+
$sysInfo.Rename("#{new_resource.hostname}")
|
243
|
+
EOH
|
244
|
+
end
|
245
245
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
246
|
+
# reboot because $windows
|
247
|
+
reboot "setting hostname" do
|
248
|
+
reason "#{Chef::Dist::PRODUCT} updated system hostname"
|
249
|
+
only_if { new_resource.windows_reboot }
|
250
|
+
action :request_reboot
|
251
|
+
end
|
251
252
|
end
|
252
253
|
end
|
253
254
|
end
|
@@ -76,20 +76,20 @@ class Chef
|
|
76
76
|
property :start_calendar_interval, [Hash, Array],
|
77
77
|
description: "A Hash (similar to crontab) that defines the calendar frequency at which a job is started or an Array.",
|
78
78
|
coerce: proc { |type|
|
79
|
-
|
79
|
+
# Coerce into an array of hashes to make validation easier
|
80
80
|
array = if type.is_a?(Array)
|
81
81
|
type
|
82
82
|
else
|
83
83
|
[type]
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
# Check to make sure that our array only has hashes
|
87
87
|
unless array.all? { |obj| obj.is_a?(Hash) }
|
88
88
|
error_msg = "start_calendar_interval must be a single hash or an array of hashes!"
|
89
89
|
raise Chef::Exceptions::ValidationFailed, error_msg
|
90
90
|
end
|
91
91
|
|
92
|
-
|
92
|
+
# Make sure the hashes don't have any incorrect keys/values
|
93
93
|
array.each do |entry|
|
94
94
|
allowed_keys = %w{Minute Hour Day Weekday Month}
|
95
95
|
unless entry.keys.all? { |key| allowed_keys.include?(key) }
|
@@ -105,7 +105,7 @@ class Chef
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
|
108
|
+
# Don't return array if we only have one entry
|
109
109
|
if array.size == 1
|
110
110
|
array.first
|
111
111
|
else
|
@@ -65,6 +65,12 @@ class Chef
|
|
65
65
|
|
66
66
|
LWRPBase.loaded_lwrps[filename] = true
|
67
67
|
|
68
|
+
unless resource_class.resource_name.nil?
|
69
|
+
if Chef.resource_handler_map.get(node, resource_class.resource_name, canonical: true) == resource_class
|
70
|
+
Chef.deprecated(:resource_name_without_provides, "Resource #{resource_class.resource_name} needs `provides :#{resource_class.resource_name}` in addition to `resource_name :#{resource_class.resource_name}` declaration")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
68
74
|
# wire up the default resource name after the class is parsed only if we haven't declared one.
|
69
75
|
# (this ordering is important for MapCollision deprecation warnings)
|
70
76
|
resource_class.resource_name resource_name.to_sym if resource_class.resource_name.nil?
|
@@ -103,6 +109,7 @@ class Chef
|
|
103
109
|
protected
|
104
110
|
|
105
111
|
attr_writer :loaded_lwrps
|
112
|
+
|
106
113
|
def loaded_lwrps
|
107
114
|
@loaded_lwrps ||= {}
|
108
115
|
end
|
@@ -61,9 +61,9 @@ class Chef
|
|
61
61
|
desired_state: false,
|
62
62
|
skip_docs: true
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
# coerce various ways of representing a boolean into either 0 (false) or 1 (true)
|
65
|
+
# which is what the defaults CLI expects. Why? Well defaults itself accepts a few
|
66
|
+
# different formats, but when you do a read command it all comes back as 1 or 0.
|
67
67
|
def coerce_booleans(val)
|
68
68
|
return 1 if [true, "TRUE", "1", "true", "YES", "yes"].include?(val)
|
69
69
|
return 0 if [false, "FALSE", "0", "false", "NO", "no"].include?(val)
|
@@ -44,6 +44,11 @@ class Chef
|
|
44
44
|
|
45
45
|
property :checksum, String, desired_state: false,
|
46
46
|
description: "SHA-256 digest used to verify the checksum of the downloaded MSU package."
|
47
|
+
|
48
|
+
property :timeout, [String, Integer],
|
49
|
+
default: 3600,
|
50
|
+
description: "The amount of time (in seconds) to wait before timing out.",
|
51
|
+
desired_state: false
|
47
52
|
end
|
48
53
|
end
|
49
54
|
end
|
@@ -88,7 +88,7 @@ class Chef
|
|
88
88
|
|
89
89
|
r = with_run_context :root do
|
90
90
|
find_resource(:template, "update ssh known hosts file #{new_resource.file_location}") do
|
91
|
-
source ::File.expand_path("
|
91
|
+
source ::File.expand_path("support/ssh_known_hosts.erb", __dir__)
|
92
92
|
local true
|
93
93
|
path new_resource.file_location
|
94
94
|
owner new_resource.owner
|
data/lib/chef/resource/sudo.rb
CHANGED
@@ -172,7 +172,7 @@ class Chef
|
|
172
172
|
end
|
173
173
|
else
|
174
174
|
declare_resource(:template, file_path) do
|
175
|
-
source ::File.expand_path("
|
175
|
+
source ::File.expand_path("support/sudoer.erb", __dir__)
|
176
176
|
local true
|
177
177
|
mode "0440"
|
178
178
|
variables sudoer: (new_resource.groups + new_resource.users).join(","),
|
@@ -228,7 +228,7 @@ class Chef
|
|
228
228
|
end
|
229
229
|
|
230
230
|
def visudo_content(path)
|
231
|
-
if ::File.
|
231
|
+
if ::File.exist?(path)
|
232
232
|
"cat #{new_resource.config_prefix}/sudoers | #{new_resource.visudo_binary} -cf - && #{new_resource.visudo_binary} -cf %{path}"
|
233
233
|
else
|
234
234
|
"cat #{new_resource.config_prefix}/sudoers %{path} | #{new_resource.visudo_binary} -cf -"
|
@@ -163,8 +163,12 @@ class Chef
|
|
163
163
|
|
164
164
|
# @return [Array] features the user has requested to install which need installation
|
165
165
|
def features_to_install
|
166
|
-
# the intersection of the features to install & disabled features are what needs installing
|
167
|
-
@
|
166
|
+
# the intersection of the features to install & disabled/removed features are what needs installing
|
167
|
+
@features_to_install ||= begin
|
168
|
+
features = node["powershell_features_cache"]["disabled"]
|
169
|
+
features |= node["powershell_features_cache"]["removed"] if new_resource.source
|
170
|
+
new_resource.feature_name & features
|
171
|
+
end
|
168
172
|
end
|
169
173
|
|
170
174
|
# @return [Array] features the user has requested to remove which need removing
|
@@ -41,7 +41,7 @@ class Chef
|
|
41
41
|
description: "The local address the firewall rule applies to."
|
42
42
|
|
43
43
|
property :local_port, [String, Integer, Array],
|
44
|
-
|
44
|
+
# split various formats of comma separated lists and provide a sorted array of strings to match PS output
|
45
45
|
coerce: proc { |d| d.is_a?(String) ? d.split(/\s*,\s*/).sort : Array(d).sort.map(&:to_s) },
|
46
46
|
description: "The local port the firewall rule applies to."
|
47
47
|
|
@@ -49,7 +49,7 @@ class Chef
|
|
49
49
|
description: "The remote address the firewall rule applies to."
|
50
50
|
|
51
51
|
property :remote_port, [String, Integer, Array],
|
52
|
-
|
52
|
+
# split various formats of comma separated lists and provide a sorted array of strings to match PS output
|
53
53
|
coerce: proc { |d| d.is_a?(String) ? d.split(/\s*,\s*/).sort : Array(d).sort.map(&:to_s) },
|
54
54
|
description: "The remote port the firewall rule applies to."
|
55
55
|
|
@@ -72,7 +72,7 @@ class Chef
|
|
72
72
|
description: "The profile the firewall rule applies to.",
|
73
73
|
coerce: proc { |p| Array(p).map(&:downcase).map(&:to_sym).sort },
|
74
74
|
callbacks: {
|
75
|
-
"contains values not in :public, :private :domain, :any or :notapplicable" => lambda { |p|
|
75
|
+
"contains values not in :public, :private, :domain, :any or :notapplicable" => lambda { |p|
|
76
76
|
p.all? { |e| %i{public private domain any notapplicable}.include?(e) }
|
77
77
|
},
|
78
78
|
}
|
@@ -106,6 +106,10 @@ class Chef
|
|
106
106
|
else
|
107
107
|
state = Chef::JSONCompat.from_json(output.stdout)
|
108
108
|
end
|
109
|
+
|
110
|
+
# Need to reverse `$rule.Profile.ToString()` in powershell command
|
111
|
+
current_profiles = state["profile"].split(", ").map(&:to_sym)
|
112
|
+
|
109
113
|
local_address state["local_address"]
|
110
114
|
local_port Array(state["local_port"]).sort
|
111
115
|
remote_address state["remote_address"]
|
@@ -113,7 +117,7 @@ class Chef
|
|
113
117
|
direction state["direction"]
|
114
118
|
protocol state["protocol"]
|
115
119
|
firewall_action state["firewall_action"]
|
116
|
-
profile
|
120
|
+
profile current_profiles
|
117
121
|
program state["program"]
|
118
122
|
service state["service"]
|
119
123
|
interface_type state["interface_type"]
|
@@ -90,8 +90,9 @@ class Chef
|
|
90
90
|
def font_exists?
|
91
91
|
require "win32ole" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
92
92
|
fonts_dir = WIN32OLE.new("WScript.Shell").SpecialFolders("Fonts")
|
93
|
+
fonts_dir_local = Chef::Util::PathHelper.join(ENV["home"], "AppData/Local/Microsoft/Windows/fonts")
|
93
94
|
logger.trace("Seeing if the font at #{Chef::Util::PathHelper.join(fonts_dir, new_resource.font_name)} exists")
|
94
|
-
::File.exist?(Chef::Util::PathHelper.join(fonts_dir, new_resource.font_name))
|
95
|
+
::File.exist?(Chef::Util::PathHelper.join(fonts_dir, new_resource.font_name)) || ::File.exist?(Chef::Util::PathHelper.join(fonts_dir_local, new_resource.font_name))
|
95
96
|
end
|
96
97
|
|
97
98
|
# Parse out the schema provided to us to see if it's one we support via remote_file.
|
@@ -149,8 +149,8 @@ class Chef
|
|
149
149
|
raise "The windows_share resource relies on PowerShell cmdlets not present in Windows releases prior to 8/2012. Cannot continue!" if node["platform_version"].to_f < 6.3
|
150
150
|
end
|
151
151
|
|
152
|
-
# given the string output of Get-SmbShareAccess parse out
|
153
|
-
# arrays of full access users, change users, and read only users
|
152
|
+
# given the string output of Get-SmbShareAccess parse out
|
153
|
+
# arrays of full access users, change users, and read only users
|
154
154
|
def parse_permissions(results_string)
|
155
155
|
json_results = Chef::JSONCompat.from_json(results_string)
|
156
156
|
json_results = [json_results] unless json_results.is_a?(Array) # single result is not an array
|
@@ -171,8 +171,8 @@ class Chef
|
|
171
171
|
[f_users, c_users, r_users]
|
172
172
|
end
|
173
173
|
|
174
|
-
# local names are returned from Get-SmbShareAccess in the full format MACHINE\\NAME
|
175
|
-
# but users of this resource would simply say NAME so we need to strip the values for comparison
|
174
|
+
# local names are returned from Get-SmbShareAccess in the full format MACHINE\\NAME
|
175
|
+
# but users of this resource would simply say NAME so we need to strip the values for comparison
|
176
176
|
def stripped_account(name)
|
177
177
|
name.slice!("#{node["hostname"]}\\")
|
178
178
|
name
|
@@ -159,16 +159,16 @@ class Chef
|
|
159
159
|
|
160
160
|
private
|
161
161
|
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
## Resource is not idempotent when day, start_day is not provided with frequency :weekly
|
163
|
+
## we set start_day when not given by user as current date based on which we set the day property for current current date day is monday ..
|
164
|
+
## we set the monday as the day so at next run when new_resource.day is nil and current_resource day is monday due to which udpate gets called
|
165
165
|
def idempotency_warning_for_frequency_weekly(day, start_day)
|
166
166
|
if start_day.nil? && day.nil?
|
167
167
|
logger.warn "To maintain idempotency for frequency :weekly provide start_day, start_time and day."
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
-
|
171
|
+
# Validate the passed value is numeric values only if it is a string
|
172
172
|
def numeric_value_in_string?(val)
|
173
173
|
return true if Integer(val)
|
174
174
|
rescue ArgumentError
|
@@ -194,7 +194,7 @@ class Chef
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
|
197
|
+
# returns true if frequency_modifer has values First, second, third, fourth, last, lastday
|
198
198
|
def frequency_modifier_includes_days_of_weeks?(frequency_modifier)
|
199
199
|
frequency_modifier = frequency_modifier.to_s.split(",")
|
200
200
|
frequency_modifier.map! { |value| value.strip.upcase }
|
@@ -209,7 +209,7 @@ class Chef
|
|
209
209
|
raise ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60')." unless numeric_value_in_string?(random_delay)
|
210
210
|
end
|
211
211
|
|
212
|
-
|
212
|
+
# @todo when we drop ruby 2.3 support this should be converted to .match?() instead of =~f
|
213
213
|
def validate_start_day(start_day, frequency)
|
214
214
|
if start_day && frequency == :none
|
215
215
|
raise ArgumentError, "`start_day` property is not supported with frequency: #{frequency}"
|
@@ -221,7 +221,7 @@ class Chef
|
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
224
|
-
|
224
|
+
# @todo when we drop ruby 2.3 support this should be converted to .match?() instead of =~
|
225
225
|
def validate_start_time(start_time, frequency)
|
226
226
|
if start_time
|
227
227
|
raise ArgumentError, "`start_time` property is not supported with `frequency :none`" if frequency == :none
|
@@ -321,7 +321,7 @@ class Chef
|
|
321
321
|
end
|
322
322
|
end
|
323
323
|
|
324
|
-
|
324
|
+
# This method returns true if day has values from 1-31 which is a days of moths and used with frequency :monthly
|
325
325
|
def days_includes_days_of_months?(days)
|
326
326
|
days.map! { |day| day.to_s.strip.downcase }
|
327
327
|
(days - VALID_DAYS_OF_MONTH).empty?
|
@@ -339,11 +339,11 @@ class Chef
|
|
339
339
|
end
|
340
340
|
end
|
341
341
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
342
|
+
# Converts the number of seconds to an ISO8601 duration format and returns it.
|
343
|
+
# Ref : https://github.com/arnau/ISO8601/blob/master/lib/iso8601/duration.rb#L18-L23
|
344
|
+
# e.g.
|
345
|
+
# ISO8601::Duration.new(65707200).to_s
|
346
|
+
# returns 'PT65707200S'
|
347
347
|
def sec_to_dur(seconds)
|
348
348
|
ISO8601::Duration.new(seconds.to_i).to_s
|
349
349
|
end
|