chef 15.11.3-universal-mingw32 → 15.15.0-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 +7 -9
- data/README.md +3 -3
- data/chef-universal-mingw32.gemspec +2 -2
- data/chef.gemspec +12 -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 +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/data_bag.rb +2 -2
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/deprecated.rb +12 -0
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +2 -0
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/exceptions.rb +3 -0
- data/lib/chef/http.rb +2 -1
- data/lib/chef/knife/bootstrap.rb +8 -10
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
- 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/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/exec.rb +2 -2
- data/lib/chef/knife/ssh.rb +20 -1
- data/lib/chef/log.rb +1 -1
- data/lib/chef/mixin/openssl_helper.rb +26 -3
- data/lib/chef/mixin/template.rb +1 -0
- 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 +1 -1
- 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/upstart.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/cron_access.rb +13 -5
- data/lib/chef/resource/cron_d.rb +2 -1
- data/lib/chef/resource/homebrew_cask.rb +3 -3
- data/lib/chef/resource/hostname.rb +19 -18
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/lwrp_base.rb +7 -0
- 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_font.rb +2 -1
- 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/powershell/cmdlet.rb +1 -1
- data/lib/chef/version.rb +2 -2
- data/lib/chef/win32/file.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/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 +1 -1
- data/spec/functional/resource/user/mac_user_spec.rb +1 -1
- 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/shell_spec.rb +5 -5
- 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 -8
- 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 +2 -2
- 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 +16 -16
- 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/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/package/dnf/python_helper_spec.rb +1 -1
- 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 +7 -7
- 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_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_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 +38 -19
@@ -32,8 +32,8 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def load_current_resource
|
35
|
-
raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.
|
36
|
-
raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf")
|
35
|
+
raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exist?("/etc/rc.conf")
|
36
|
+
raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless /DAEMONS=\((.*)\)/m.match?(::File.read("/etc/rc.conf"))
|
37
37
|
|
38
38
|
super
|
39
39
|
|
@@ -45,7 +45,7 @@ class Chef
|
|
45
45
|
shared_resource_requirements
|
46
46
|
requirements.assert(:all_actions) do |a|
|
47
47
|
update_rcd = "/usr/sbin/update-rc.d"
|
48
|
-
a.assertion { ::File.
|
48
|
+
a.assertion { ::File.exist? update_rcd }
|
49
49
|
a.failure_message Chef::Exceptions::Service, "#{update_rcd} does not exist!"
|
50
50
|
# no whyrun recovery - this is a base system component of debian
|
51
51
|
# distros and must be present
|
@@ -34,7 +34,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
|
|
34
34
|
@current_resource.enabled(
|
35
35
|
Dir.glob("/etc/runlevels/**/#{Chef::Util::PathHelper.escape_glob_dir(@current_resource.service_name)}").any? do |file|
|
36
36
|
@found_script = true
|
37
|
-
exists = ::File.
|
37
|
+
exists = ::File.exist? file
|
38
38
|
readable = ::File.readable? file
|
39
39
|
logger.trace "#{@new_resource} exists: #{exists}, readable: #{readable}"
|
40
40
|
exists && readable
|
@@ -47,7 +47,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
|
|
47
47
|
|
48
48
|
def define_resource_requirements
|
49
49
|
requirements.assert(:all_actions) do |a|
|
50
|
-
a.assertion { ::File.
|
50
|
+
a.assertion { ::File.exist?("/sbin/rc-update") }
|
51
51
|
a.failure_message Chef::Exceptions::Service, "/sbin/rc-update does not exist"
|
52
52
|
# no whyrun recovery -t his is a core component whose presence is
|
53
53
|
# unlikely to be affected by what we do in the course of a chef run
|
@@ -84,7 +84,7 @@ class Chef
|
|
84
84
|
end
|
85
85
|
|
86
86
|
requirements.assert(:all_actions) do |a|
|
87
|
-
a.assertion { ::File.
|
87
|
+
a.assertion { ::File.exist?(@plist.to_s) }
|
88
88
|
a.failure_message Chef::Exceptions::Service,
|
89
89
|
"Could not find plist for #{@new_resource}"
|
90
90
|
end
|
@@ -215,7 +215,7 @@ class Chef
|
|
215
215
|
return nil if @plist.nil?
|
216
216
|
|
217
217
|
# Plist must exist by this point
|
218
|
-
raise Chef::Exceptions::FileNotFound, "Cannot find #{@plist}!" unless ::File.
|
218
|
+
raise Chef::Exceptions::FileNotFound, "Cannot find #{@plist}!" unless ::File.exist?(@plist)
|
219
219
|
|
220
220
|
# Most services have the same internal label as the name of the
|
221
221
|
# plist file. However, there is no rule saying that *has* to be
|
@@ -132,7 +132,7 @@ class Chef
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def update_rcl(value)
|
135
|
-
FileUtils.touch RC_CONF_LOCAL_PATH unless ::File.
|
135
|
+
FileUtils.touch RC_CONF_LOCAL_PATH unless ::File.exist? RC_CONF_LOCAL_PATH
|
136
136
|
::File.write(RC_CONF_LOCAL_PATH, value)
|
137
137
|
@rc_conf_local = value
|
138
138
|
end
|
@@ -56,7 +56,7 @@ class Chef
|
|
56
56
|
|
57
57
|
requirements.assert(:all_actions) do |a|
|
58
58
|
chkconfig_file = "/sbin/chkconfig"
|
59
|
-
a.assertion { ::File.
|
59
|
+
a.assertion { ::File.exist? chkconfig_file }
|
60
60
|
a.failure_message Chef::Exceptions::Service, "#{chkconfig_file} does not exist!"
|
61
61
|
end
|
62
62
|
|
@@ -80,7 +80,7 @@ class Chef
|
|
80
80
|
|
81
81
|
super
|
82
82
|
|
83
|
-
if ::File.
|
83
|
+
if ::File.exist?("/sbin/chkconfig")
|
84
84
|
chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", returns: [0, 1])
|
85
85
|
unless run_levels.nil? || run_levels.empty?
|
86
86
|
all_levels_match = true
|
@@ -135,7 +135,7 @@ class Chef
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
# Get enabled/disabled state by reading job configuration file
|
138
|
-
if ::File.
|
138
|
+
if ::File.exist?("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
|
139
139
|
logger.trace("#{@new_resource} found #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
|
140
140
|
::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}", "r") do |file|
|
141
141
|
while line = file.gets
|
@@ -37,7 +37,7 @@ class Chef
|
|
37
37
|
if template_available?(new_resource.source)
|
38
38
|
source new_resource.source
|
39
39
|
else
|
40
|
-
source ::File.expand_path("
|
40
|
+
source ::File.expand_path("support/yum_repo.erb", __dir__)
|
41
41
|
local true
|
42
42
|
end
|
43
43
|
sensitive new_resource.sensitive
|
@@ -41,7 +41,7 @@ class Chef
|
|
41
41
|
if template_available?(new_resource.source)
|
42
42
|
source new_resource.source
|
43
43
|
else
|
44
|
-
source ::File.expand_path("
|
44
|
+
source ::File.expand_path("support/zypper_repo.erb", __dir__)
|
45
45
|
local true
|
46
46
|
end
|
47
47
|
sensitive new_resource.sensitive
|
@@ -115,28 +115,48 @@ class Chef
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
# the version of gpg installed on the system
|
119
|
+
#
|
120
|
+
# @return [Gem::Version] the version of GPG
|
121
|
+
def gpg_version
|
122
|
+
so = shell_out!("gpg --version")
|
123
|
+
# matches 2.0 and 2.2 versions from SLES 12 and 15: https://rubular.com/r/e6D0WfGK6SXvUp
|
124
|
+
version = /gpg \(GnuPG\)\s*(.*)/.match(so.stdout)[1]
|
125
|
+
logger.trace("GPG package version is #{version}")
|
126
|
+
Gem::Version.new(version)
|
127
|
+
end
|
128
|
+
|
118
129
|
# is the provided key already installed
|
119
130
|
# @param [String] key_path the path to the key on the local filesystem
|
120
131
|
#
|
121
132
|
# @return [boolean] is the key already known by rpm
|
122
133
|
def key_installed?(key_path)
|
123
|
-
so = shell_out("rpm -qa gpg-pubkey*")
|
134
|
+
so = shell_out("/bin/rpm -qa gpg-pubkey*")
|
124
135
|
# expected output & match: http://rubular.com/r/RdF7EcXEtb
|
125
|
-
status = /gpg-pubkey-#{
|
136
|
+
status = /gpg-pubkey-#{short_key_id(key_path)}/.match(so.stdout)
|
126
137
|
logger.trace("GPG key at #{key_path} is known by rpm? #{status ? "true" : "false"}")
|
127
138
|
status
|
128
139
|
end
|
129
140
|
|
130
|
-
# extract the gpg key
|
141
|
+
# extract the gpg key's short key id from a local file. Learning moment: This 8 hex value ID
|
142
|
+
# is sometimes incorrectly called the fingerprint. The fingerprint is the full length value
|
143
|
+
# and googling for that will just result in sad times.
|
144
|
+
#
|
131
145
|
# @param [String] key_path the path to the key on the local filesystem
|
132
146
|
#
|
133
|
-
# @return [String] the
|
134
|
-
def
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
147
|
+
# @return [String] the short key id of the key
|
148
|
+
def short_key_id(key_path)
|
149
|
+
if gpg_version >= Gem::Version.new("2.2") # SLES 15+
|
150
|
+
so = shell_out!("gpg --import-options import-show --dry-run --import --with-colons #{key_path}")
|
151
|
+
# expected output and match: https://rubular.com/r/uXWJo3yfkli1qA
|
152
|
+
short_key_id = /fpr:*\h*(\h{8}):/.match(so.stdout)[1].downcase
|
153
|
+
else # SLES 12 and earlier
|
154
|
+
so = shell_out!("gpg --with-fingerprint #{key_path}")
|
155
|
+
# expected output and match: http://rubular.com/r/BpfMjxySQM
|
156
|
+
short_key_id = %r{pub\s*\S*/(\S*)}.match(so.stdout)[1].downcase
|
157
|
+
end
|
158
|
+
logger.trace("GPG short key ID of key at #{key_path} is #{short_key_id}")
|
159
|
+
short_key_id
|
140
160
|
end
|
141
161
|
|
142
162
|
# install the provided gpg key
|
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
|
|
@@ -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,9 +289,10 @@ 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
|
+
sensitive new_resource.sensitive
|
295
296
|
variables(
|
296
297
|
name: sanitized_name,
|
297
298
|
predefined_value: new_resource.predefined_value,
|
@@ -59,7 +59,7 @@ class Chef
|
|
59
59
|
|
60
60
|
unless casked?
|
61
61
|
converge_by("install cask #{new_resource.cask_name} #{new_resource.options}") do
|
62
|
-
shell_out!("#{new_resource.homebrew_path} cask
|
62
|
+
shell_out!("#{new_resource.homebrew_path} install --cask #{new_resource.cask_name} #{new_resource.options}",
|
63
63
|
user: new_resource.owner,
|
64
64
|
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
|
65
65
|
cwd: ::Dir.home(new_resource.owner))
|
@@ -74,7 +74,7 @@ class Chef
|
|
74
74
|
|
75
75
|
if casked?
|
76
76
|
converge_by("uninstall cask #{new_resource.cask_name}") do
|
77
|
-
shell_out!("#{new_resource.homebrew_path} cask
|
77
|
+
shell_out!("#{new_resource.homebrew_path} uninstall --cask #{new_resource.cask_name}",
|
78
78
|
user: new_resource.owner,
|
79
79
|
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
|
80
80
|
cwd: ::Dir.home(new_resource.owner))
|
@@ -92,7 +92,7 @@ class Chef
|
|
92
92
|
# @return [Boolean]
|
93
93
|
def casked?
|
94
94
|
unscoped_name = new_resource.cask_name.split("/").last
|
95
|
-
shell_out!("#{new_resource.homebrew_path} cask
|
95
|
+
shell_out!("#{new_resource.homebrew_path} list --cask 2>/dev/null",
|
96
96
|
user: new_resource.owner,
|
97
97
|
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
|
98
98
|
cwd: ::Dir.home(new_resource.owner)).stdout.split.include?(unscoped_name)
|
@@ -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
|
data/lib/chef/resource/locale.rb
CHANGED
@@ -97,7 +97,7 @@ class Chef
|
|
97
97
|
# @raise [Mixlib::ShellOut::ShellCommandFailed] not a supported language or locale
|
98
98
|
#
|
99
99
|
def generate_locales
|
100
|
-
shell_out!("locale-gen #{unavailable_locales.join(" ")}")
|
100
|
+
shell_out!("locale-gen #{unavailable_locales.join(" ")}", timeout: 1800)
|
101
101
|
end
|
102
102
|
|
103
103
|
# Updates system locale by appropriately writing them in /etc/locale.conf
|