chef 15.8.23-universal-mingw32 → 15.9.17-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/README.md +1 -1
  4. data/Rakefile +9 -0
  5. data/distro/powershell/chef/chef.psm1 +459 -459
  6. data/distro/templates/powershell/chef/chef.psm1.erb +459 -0
  7. data/lib/chef/application.rb +1 -1
  8. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  9. data/lib/chef/chef_fs/command_line.rb +5 -5
  10. data/lib/chef/cookbook/metadata.rb +5 -4
  11. data/lib/chef/cookbook/synchronizer.rb +1 -0
  12. data/lib/chef/cookbook_loader.rb +1 -1
  13. data/lib/chef/data_collector/config_validation.rb +7 -7
  14. data/lib/chef/deprecated.rb +5 -5
  15. data/lib/chef/dsl/platform_introspection.rb +2 -2
  16. data/lib/chef/dsl/reboot_pending.rb +3 -3
  17. data/lib/chef/http/json_output.rb +1 -1
  18. data/lib/chef/knife.rb +1 -1
  19. data/lib/chef/knife/bootstrap/templates/README.md +2 -2
  20. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  21. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +2 -2
  22. data/lib/chef/knife/core/ui.rb +1 -1
  23. data/lib/chef/knife/core/windows_bootstrap_context.rb +8 -8
  24. data/lib/chef/knife/data_bag_edit.rb +2 -2
  25. data/lib/chef/knife/edit.rb +1 -1
  26. data/lib/chef/knife/environment_compare.rb +1 -1
  27. data/lib/chef/knife/list.rb +1 -1
  28. data/lib/chef/mixin/api_version_request_handling.rb +1 -1
  29. data/lib/chef/provider/group/usermod.rb +2 -5
  30. data/lib/chef/provider/mount/mount.rb +1 -1
  31. data/lib/chef/provider/package/homebrew.rb +1 -2
  32. data/lib/chef/provider/package/rubygems.rb +1 -1
  33. data/lib/chef/provider/package/yum/python_helper.rb +2 -2
  34. data/lib/chef/provider/package/yum/rpm_utils.rb +4 -4
  35. data/lib/chef/provider/package/zypper.rb +2 -1
  36. data/lib/chef/provider/remote_file.rb +2 -2
  37. data/lib/chef/provider/route.rb +4 -4
  38. data/lib/chef/provider/windows_env.rb +3 -3
  39. data/lib/chef/resource.rb +7 -2
  40. data/lib/chef/resource/build_essential.rb +46 -22
  41. data/lib/chef/resource/cron.rb +1 -1
  42. data/lib/chef/resource/cron_d.rb +1 -1
  43. data/lib/chef/resource/execute.rb +1 -1
  44. data/lib/chef/resource/freebsd_package.rb +0 -3
  45. data/lib/chef/resource/homebrew_package.rb +1 -2
  46. data/lib/chef/resource/hostname.rb +2 -2
  47. data/lib/chef/resource/kernel_module.rb +3 -2
  48. data/lib/chef/resource/openbsd_package.rb +0 -3
  49. data/lib/chef/resource/remote_file.rb +1 -1
  50. data/lib/chef/resource/rhsm_errata.rb +9 -2
  51. data/lib/chef/resource/rhsm_errata_level.rb +11 -5
  52. data/lib/chef/resource/rhsm_register.rb +27 -12
  53. data/lib/chef/resource/swap_file.rb +2 -2
  54. data/lib/chef/resource/timezone.rb +2 -2
  55. data/lib/chef/resource/windows_certificate.rb +0 -2
  56. data/lib/chef/resource/windows_share.rb +1 -1
  57. data/lib/chef/shell/ext.rb +1 -1
  58. data/lib/chef/util/diff.rb +3 -3
  59. data/lib/chef/util/selinux.rb +2 -2
  60. data/lib/chef/version.rb +1 -1
  61. data/lib/chef/win32/error.rb +1 -1
  62. data/lib/chef/win32/registry.rb +1 -1
  63. data/spec/data/cookbooks/starter/recipes/default.rb +1 -1
  64. data/spec/data/windows_certificates/base64_test.cer +18 -20
  65. data/spec/data/windows_certificates/othertest.cer +0 -0
  66. data/spec/data/windows_certificates/test.cer +0 -0
  67. data/spec/data/windows_certificates/test.p7b +0 -0
  68. data/spec/data/windows_certificates/test.pem +18 -19
  69. data/spec/data/windows_certificates/test.pfx +0 -0
  70. data/spec/functional/resource/ifconfig_spec.rb +2 -2
  71. data/spec/functional/resource/windows_certificate_spec.rb +9 -9
  72. data/spec/functional/resource/windows_service_spec.rb +1 -2
  73. data/spec/functional/run_lock_spec.rb +7 -1
  74. data/spec/functional/win32/service_manager_spec.rb +1 -1
  75. data/spec/functional/win32/version_info_spec.rb +4 -4
  76. data/spec/integration/client/client_spec.rb +2 -2
  77. data/spec/integration/client/exit_code_spec.rb +1 -0
  78. data/spec/integration/client/ipv6_spec.rb +1 -0
  79. data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -0
  80. data/spec/integration/knife/chef_repo_path_spec.rb +1 -0
  81. data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -0
  82. data/spec/integration/knife/chefignore_spec.rb +1 -0
  83. data/spec/integration/knife/client_bulk_delete_spec.rb +1 -0
  84. data/spec/integration/knife/client_create_spec.rb +1 -0
  85. data/spec/integration/knife/client_delete_spec.rb +1 -0
  86. data/spec/integration/knife/client_key_create_spec.rb +1 -0
  87. data/spec/integration/knife/client_key_delete_spec.rb +1 -0
  88. data/spec/integration/knife/client_key_list_spec.rb +1 -0
  89. data/spec/integration/knife/client_key_show_spec.rb +1 -0
  90. data/spec/integration/knife/client_list_spec.rb +1 -0
  91. data/spec/integration/knife/client_show_spec.rb +1 -0
  92. data/spec/integration/knife/common_options_spec.rb +1 -0
  93. data/spec/integration/knife/config_get_profile_spec.rb +1 -0
  94. data/spec/integration/knife/config_get_spec.rb +1 -0
  95. data/spec/integration/knife/config_list_profiles_spec.rb +1 -0
  96. data/spec/integration/knife/config_use_profile_spec.rb +1 -0
  97. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -0
  98. data/spec/integration/knife/cookbook_bulk_delete_spec.rb +1 -0
  99. data/spec/integration/knife/cookbook_download_spec.rb +1 -0
  100. data/spec/integration/knife/cookbook_list_spec.rb +1 -0
  101. data/spec/integration/knife/cookbook_show_spec.rb +1 -0
  102. data/spec/integration/knife/cookbook_upload_spec.rb +1 -0
  103. data/spec/integration/knife/data_bag_create_spec.rb +1 -0
  104. data/spec/integration/knife/data_bag_delete_spec.rb +1 -0
  105. data/spec/integration/knife/data_bag_edit_spec.rb +1 -0
  106. data/spec/integration/knife/data_bag_from_file_spec.rb +1 -0
  107. data/spec/integration/knife/data_bag_list_spec.rb +1 -0
  108. data/spec/integration/knife/data_bag_show_spec.rb +1 -0
  109. data/spec/integration/knife/delete_spec.rb +1 -0
  110. data/spec/integration/knife/deps_spec.rb +3 -2
  111. data/spec/integration/knife/diff_spec.rb +1 -0
  112. data/spec/integration/knife/download_spec.rb +1 -0
  113. data/spec/integration/knife/environment_compare_spec.rb +1 -0
  114. data/spec/integration/knife/environment_create_spec.rb +1 -0
  115. data/spec/integration/knife/environment_delete_spec.rb +1 -0
  116. data/spec/integration/knife/environment_from_file_spec.rb +1 -0
  117. data/spec/integration/knife/environment_list_spec.rb +1 -0
  118. data/spec/integration/knife/environment_show_spec.rb +1 -0
  119. data/spec/integration/knife/list_spec.rb +1 -0
  120. data/spec/integration/knife/node_bulk_delete_spec.rb +1 -0
  121. data/spec/integration/knife/node_create_spec.rb +1 -0
  122. data/spec/integration/knife/node_delete_spec.rb +1 -0
  123. data/spec/integration/knife/node_environment_set_spec.rb +1 -0
  124. data/spec/integration/knife/node_from_file_spec.rb +1 -0
  125. data/spec/integration/knife/node_list_spec.rb +1 -0
  126. data/spec/integration/knife/node_run_list_add_spec.rb +1 -0
  127. data/spec/integration/knife/node_run_list_remove_spec.rb +1 -0
  128. data/spec/integration/knife/node_run_list_set_spec.rb +1 -0
  129. data/spec/integration/knife/node_show_spec.rb +1 -0
  130. data/spec/integration/knife/raw_spec.rb +1 -0
  131. data/spec/integration/knife/redirection_spec.rb +1 -0
  132. data/spec/integration/knife/role_bulk_delete_spec.rb +1 -0
  133. data/spec/integration/knife/role_create_spec.rb +1 -0
  134. data/spec/integration/knife/role_delete_spec.rb +1 -0
  135. data/spec/integration/knife/role_from_file_spec.rb +1 -0
  136. data/spec/integration/knife/role_list_spec.rb +1 -0
  137. data/spec/integration/knife/role_show_spec.rb +1 -0
  138. data/spec/integration/knife/search_node_spec.rb +1 -0
  139. data/spec/integration/knife/show_spec.rb +1 -0
  140. data/spec/integration/knife/upload_spec.rb +1 -0
  141. data/spec/integration/recipes/accumulator_spec.rb +1 -0
  142. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -0
  143. data/spec/integration/recipes/lwrp_spec.rb +1 -0
  144. data/spec/integration/recipes/notifies_spec.rb +1 -0
  145. data/spec/integration/recipes/notifying_block_spec.rb +1 -0
  146. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -0
  147. data/spec/integration/recipes/resource_action_spec.rb +1 -0
  148. data/spec/integration/recipes/unified_mode_spec.rb +1 -0
  149. data/spec/integration/solo/solo_spec.rb +1 -0
  150. data/spec/spec_helper.rb +7 -10
  151. data/spec/support/chef_helpers.rb +1 -1
  152. data/spec/support/key_helpers.rb +0 -2
  153. data/spec/support/platform_helpers.rb +7 -3
  154. data/spec/support/platforms/win32/spec_service.rb +27 -25
  155. data/spec/support/shared/context/config.rb +0 -3
  156. data/spec/support/shared/integration/integration_helper.rb +0 -1
  157. data/spec/support/shared/unit/execute_resource.rb +0 -2
  158. data/spec/support/shared/unit/provider/file.rb +0 -1
  159. data/spec/support/shared/unit/script_resource.rb +2 -4
  160. data/spec/support/shared/unit/windows_script_resource.rb +0 -2
  161. data/spec/unit/cookbook/gem_installer_spec.rb +1 -1
  162. data/spec/unit/cookbook/metadata_spec.rb +1 -10
  163. data/spec/unit/data_collector_spec.rb +1 -1
  164. data/spec/unit/deprecated_spec.rb +3 -3
  165. data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +1 -1
  166. data/spec/unit/encrypted_data_bag_item_spec.rb +2 -2
  167. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +3 -3
  168. data/spec/unit/knife_spec.rb +6 -7
  169. data/spec/unit/mixin/shell_out_spec.rb +27 -29
  170. data/spec/unit/provider/file_spec.rb +1 -0
  171. data/spec/unit/resource/build_essential_spec.rb +48 -2
  172. data/spec/unit/resource/data/InstallHistory_with_CLT.plist +92 -0
  173. data/spec/unit/resource/data/InstallHistory_without_CLT.plist +38 -0
  174. data/spec/unit/resource/execute_spec.rb +1 -1
  175. data/spec/unit/resource/rhsm_register_spec.rb +24 -0
  176. data/spec/unit/resource/windows_share_spec.rb +3 -1
  177. data/tasks/rspec.rb +1 -0
  178. metadata +9 -6
@@ -2,8 +2,7 @@
2
2
  # Author:: Joshua Timberman (<joshua@chef.io>)
3
3
  # Author:: Graeme Mathieson (<mathie@woss.name>)
4
4
  #
5
- # Copyright 2011-2016, Chef Software Inc.
6
- # Copyright 2014-2016, Chef Software, Inc <legal@chef.io>
5
+ # Copyright:: 2011-2016, Chef Software, Inc <legal@chef.io>
7
6
  #
8
7
  # Licensed under the Apache License, Version 2.0 (the "License");
9
8
  # you may not use this file except in compliance with the License.
@@ -403,7 +403,7 @@ class Chef
403
403
  "Gem options must be passed to gem_package as a string instead of a hash when",
404
404
  "using this installation of #{Chef::Dist::PRODUCT} because it runs with its own packaged Ruby. A hash",
405
405
  "may only be used when installing a gem to the same Ruby installation that #{Chef::Dist::PRODUCT} is",
406
- "running under. See https://docs.chef.io/resource_gem_package.html for more information.",
406
+ "running under. See https://docs.chef.io/resources/gem_package/ for more information.",
407
407
  "Error raised at #{new_resource} from #{new_resource.source_line}",
408
408
  ].join("\n")
409
409
  raise ArgumentError, msg
@@ -88,9 +88,9 @@ class Chef
88
88
  def install_only_packages(name)
89
89
  query_output = query("installonlypkgs", { "package" => name })
90
90
  if query_output == "False"
91
- return false
91
+ false
92
92
  elsif query_output == "True"
93
- return true
93
+ true
94
94
  end
95
95
  end
96
96
 
@@ -209,9 +209,9 @@ class Chef
209
209
 
210
210
  # the most unprocessed characters left wins
211
211
  if (x_pos_max - x_pos) > (y_pos_max - y_pos)
212
- return 1
212
+ 1
213
213
  else
214
- return -1
214
+ -1
215
215
  end
216
216
  end
217
217
 
@@ -522,9 +522,9 @@ class Chef
522
522
  def lookup(package_name)
523
523
  pkgs = @rpms[package_name]
524
524
  if pkgs
525
- return pkgs.sort.reverse
525
+ pkgs.sort.reverse
526
526
  else
527
- return nil
527
+ nil
528
528
  end
529
529
  end
530
530
 
@@ -3,7 +3,8 @@
3
3
  # Authors:: Adam Jacob (<adam@chef.io>)
4
4
  # Ionuț Arțăriși (<iartarisi@suse.cz>)
5
5
  # Copyright:: Copyright 2008-2017, Chef Software Inc.
6
- # Copyright 2013-2016, SUSE Linux GmbH
6
+ # Copyright:: 2013-2016, SUSE Linux GmbH
7
+ #
7
8
  # License:: Apache License, Version 2.0
8
9
  #
9
10
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Jesse Campbell (<hikeit@gmail.com>)
3
3
  # Author:: Adam Jacob (<adam@chef.io>)
4
- # Copyright:: Copyright 2008-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2008-2020, 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");
@@ -35,7 +35,7 @@ class Chef
35
35
  requirements.assert(:all_actions) do |a|
36
36
  a.assertion do
37
37
  if prop
38
- node[:platform_family] == "windows"
38
+ windows?
39
39
  else
40
40
  true
41
41
  end
@@ -1,6 +1,7 @@
1
1
  #
2
2
  # Author:: Bryan McLellan (btm@loftninjas.org), Jesse Nelson (spheromak@gmail.com)
3
3
  # Copyright:: Copyright 2009-2016, Bryan McLellan
4
+ # Copyright:: Copyright 2020, Chef Software, Inc.
4
5
  # License:: Apache License, Version 2.0
5
6
  #
6
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -78,7 +79,7 @@ class Chef
78
79
  IPAddr.new(ip, Socket::AF_INET).to_s
79
80
  rescue ArgumentError
80
81
  logger.trace("Invalid IP address data: hex=#{hex_ip}, ip=#{ip}")
81
- return nil
82
+ nil
82
83
  end
83
84
  end
84
85
 
@@ -95,7 +96,7 @@ class Chef
95
96
  end
96
97
 
97
98
  # For linux, we use /proc/net/route file to read proc table info
98
- return if node[:os] != "linux"
99
+ return unless linux?
99
100
 
100
101
  route_file = ::File.open("/proc/net/route", "r")
101
102
 
@@ -159,8 +160,7 @@ class Chef
159
160
  end
160
161
 
161
162
  def generate_config
162
- case node[:platform_family]
163
- when "rhel", "amazon", "fedora"
163
+ if platform_family?("rhel", "amazon", "fedora")
164
164
  conf = {}
165
165
  # walk the collection
166
166
  run_context.resource_collection.each do |resource|
@@ -104,7 +104,7 @@ class Chef
104
104
  needs_delete = new_values.any? { |v| current_values.include?(v) }
105
105
  if !needs_delete
106
106
  logger.trace("#{new_resource} element '#{new_resource.value}' does not exist")
107
- return true # do not delete the key
107
+ true # do not delete the key
108
108
  else
109
109
  new_value =
110
110
  current_values.select do |item|
@@ -112,13 +112,13 @@ class Chef
112
112
  end.join(new_resource.delim)
113
113
 
114
114
  if new_value.empty?
115
- return false # nothing left here, delete the key
115
+ false # nothing left here, delete the key
116
116
  else
117
117
  old_value = new_resource.value(new_value)
118
118
  create_env
119
119
  logger.trace("#{new_resource} deleted #{old_value} element")
120
120
  new_resource.updated_by_last_action(true)
121
- return true # we removed the element and updated; do not delete the key
121
+ true # we removed the element and updated; do not delete the key
122
122
  end
123
123
  end
124
124
  end
@@ -965,6 +965,8 @@ class Chef
965
965
  @resource_name = nil
966
966
  end
967
967
  end
968
+
969
+ @resource_name = nil unless defined?(@resource_name)
968
970
  @resource_name
969
971
  end
970
972
 
@@ -990,7 +992,7 @@ class Chef
990
992
  # @param flag [Boolean] value to set unified_mode to
991
993
  # @return [Boolean] unified_mode value
992
994
  def self.unified_mode(flag = nil)
993
- @unified_mode = Chef::Config[:resource_unified_mode_default] if @unified_mode.nil?
995
+ @unified_mode = Chef::Config[:resource_unified_mode_default] if !defined?(@unified_mode) || @unified_mode.nil?
994
996
  @unified_mode = flag unless flag.nil?
995
997
  !!@unified_mode
996
998
  end
@@ -1035,7 +1037,7 @@ class Chef
1035
1037
  self.allowed_actions |= @default_action
1036
1038
  end
1037
1039
 
1038
- if @default_action
1040
+ if defined?(@default_action) && @default_action
1039
1041
  @default_action
1040
1042
  elsif superclass.respond_to?(:default_action)
1041
1043
  superclass.default_action
@@ -1366,6 +1368,9 @@ class Chef
1366
1368
  def self.provides(name, **options, &block)
1367
1369
  name = name.to_sym
1368
1370
 
1371
+ # quell warnings
1372
+ @chef_version_for_provides = nil unless defined?(@chef_version_for_provides)
1373
+
1369
1374
  # `provides :resource_name, os: 'linux'`) needs to remove the old
1370
1375
  # canonical DSL before adding the new one.
1371
1376
  if @resource_name && name == @resource_name
@@ -15,6 +15,7 @@
15
15
  #
16
16
 
17
17
  require_relative "../resource"
18
+ require "plist"
18
19
 
19
20
  class Chef
20
21
  class Resource
@@ -67,23 +68,7 @@ class Chef
67
68
  package "devel/m4"
68
69
  package "devel/gettext"
69
70
  when macos?
70
- unless xcode_cli_installed?
71
- # This script was graciously borrowed and modified from Tim Sutton's
72
- # osx-vm-templates at https://github.com/timsutton/osx-vm-templates/blob/b001475df54a9808d3d56d06e71b8fa3001fff42/scripts/xcode-cli-tools.sh
73
- execute "install XCode Command Line tools" do
74
- command <<-EOH.gsub(/^ {14}/, "")
75
- # create the placeholder file that's checked by CLI updates' .dist code
76
- # in Apple's SUS catalog
77
- touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
78
- # find the CLI Tools update. We tail here because sometimes there's 2 and newest is last
79
- PROD=$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n')
80
- # install it
81
- softwareupdate -i "$PROD" --verbose
82
- # Remove the placeholder to prevent perpetual appearance in the update utility
83
- rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
84
- EOH
85
- end
86
- end
71
+ install_xcode_cli_tools(xcode_cli_package_label) unless xcode_cli_installed?
87
72
  when omnios?
88
73
  package "developer/gcc48"
89
74
  package "developer/object-file"
@@ -142,14 +127,53 @@ class Chef
142
127
 
143
128
  action_class do
144
129
  #
145
- # Determine if the XCode Command Line Tools are installed
130
+ # Install Xcode Command Line tools via softwareupdate CLI
131
+ #
132
+ # @param [String] label The label (package name) to install
133
+ #
134
+ def install_xcode_cli_tools(label)
135
+ # This script was graciously borrowed and modified from Tim Sutton's
136
+ # osx-vm-templates at https://github.com/timsutton/osx-vm-templates/blob/b001475df54a9808d3d56d06e71b8fa3001fff42/scripts/xcode-cli-tools.sh
137
+
138
+ if label.nil?
139
+ Chef::Log.warn("Could not determine a Xcode CLI Tools package to install via softwareupdate")
140
+ else
141
+ # create the placeholder file that's checked by CLI updates' .dist code
142
+ # in Apple's SUS catalog and then remove it when we're done
143
+ execute "install Xcode Command Line tools" do
144
+ command <<-EOH
145
+ touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
146
+ softwareupdate -i "#{label}" --verbose
147
+ rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
148
+ EOH
149
+ end
150
+ end
151
+ end
152
+
153
+ #
154
+ # Determine if the XCode Command Line Tools are installed by parsing the install history plist.
155
+ # We parse the plist data install of running pkgutil because we found that pkgutils doesn't always contain all the packages
146
156
  #
147
157
  # @return [true, false]
148
158
  def xcode_cli_installed?
149
- cmd = Mixlib::ShellOut.new("pkgutil --pkgs=com.apple.pkg.CLTools_Executables")
150
- cmd.run_command
151
- # pkgutil returns an error if the package isn't found aka not installed
152
- cmd.error? ? false : true
159
+ packages = Plist.parse_xml(::File.open("/Library/Receipts/InstallHistory.plist", "r"))
160
+ packages.select! { |package| package["displayName"].match? "Command Line Tools" }
161
+ !packages.empty?
162
+ end
163
+
164
+ #
165
+ # Return to package label of the latest Xcode Command Line Tools update, if available
166
+ #
167
+ # @return [String, NilClass]
168
+ def xcode_cli_package_label
169
+ available_updates = shell_out("softwareupdate", "--list")
170
+
171
+ # raise if we fail to check
172
+ available_updates.error!
173
+
174
+ # https://rubular.com/r/UPEE5P7mZLvXNs
175
+ # this will return the match or nil
176
+ available_updates.stdout[/^\s*\* (?:Label: )?(Command Line Tools.*)/, 1]
153
177
  end
154
178
  end
155
179
 
@@ -135,7 +135,7 @@ class Chef
135
135
  end
136
136
 
137
137
  property :time, Symbol,
138
- description: "A time interval. Possible values: :annually, :daily, :hourly, :midnight, :monthly, :reboot, :weekly, or :yearly.",
138
+ description: "A time interval.",
139
139
  equal_to: Chef::Provider::Cron::SPECIAL_TIME_VALUES
140
140
 
141
141
  property :mailto, String,
@@ -146,7 +146,7 @@ class Chef
146
146
  property :cookbook, String, desired_state: false
147
147
 
148
148
  property :predefined_value, String,
149
- description: 'Schedule your cron job with one of the special predefined value instead of ** * pattern. This correspond to "@reboot", "@yearly", "@annually", "@monthly", "@weekly", "@daily", "@midnight" or "@hourly".',
149
+ description: "Schedule your cron job with one of the special predefined value instead of ** * pattern.",
150
150
  equal_to: %w{ @reboot @yearly @annually @monthly @weekly @daily @midnight @hourly }
151
151
 
152
152
  property :minute, [Integer, String],
@@ -131,7 +131,7 @@ class Chef
131
131
  end
132
132
 
133
133
  def validate_identity_platform(specified_user, password = nil, specified_domain = nil, elevated = false)
134
- if node[:platform_family] == "windows"
134
+ if windows?
135
135
  if specified_user && password.nil?
136
136
  raise ArgumentError, "A value for `password` must be specified when a value for `user` is specified on the Windows platform"
137
137
  end
@@ -21,13 +21,10 @@
21
21
  require_relative "package"
22
22
  require_relative "../provider/package/freebsd/port"
23
23
  require_relative "../provider/package/freebsd/pkgng"
24
- require_relative "../mixin/shell_out"
25
24
 
26
25
  class Chef
27
26
  class Resource
28
27
  class FreebsdPackage < Chef::Resource::Package
29
- include Chef::Mixin::ShellOut
30
-
31
28
  resource_name :freebsd_package
32
29
  provides :package, platform: "freebsd"
33
30
 
@@ -2,8 +2,7 @@
2
2
  # Author:: Joshua Timberman (<joshua@chef.io>)
3
3
  # Author:: Graeme Mathieson (<mathie@woss.name>)
4
4
  #
5
- # Copyright 2011-2016, Chef Software Inc.
6
- # Copyright 2014-2016, Chef Software, Inc <legal@chef.io>
5
+ # Copyright:: 2011-2020, Chef Software Inc.<legal@chef.io>
7
6
  #
8
7
  # Licensed under the Apache License, Version 2.0 (the "License");
9
8
  # you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@ class Chef
82
82
  action :set do
83
83
  description "Sets the node's hostname."
84
84
 
85
- if node["platform_family"] != "windows"
85
+ if !windows?
86
86
  ohai "reload hostname" do
87
87
  plugin "hostname"
88
88
  action :nothing
@@ -125,7 +125,7 @@ class Chef
125
125
  not_if { shell_out!("/usr/sbin/scutil --get LocalHostName").stdout.chomp == shortname }
126
126
  notifies :reload, "ohai[reload hostname]"
127
127
  end
128
- when node["os"] == "linux"
128
+ when linux?
129
129
  case
130
130
  when ::File.exist?("/usr/bin/hostnamectl") && !docker?
131
131
  # use hostnamectl whenever we find it on linux (as systemd takes over the world)
@@ -3,8 +3,9 @@
3
3
  #
4
4
  # The MIT License (MIT)
5
5
  #
6
- # Copyright 2016-2018, Shopify Inc.
7
- # Copyright 2018, Chef Software, Inc.
6
+ # Copyright:: 2016-2018, Shopify Inc.
7
+ # Copyright:: 2018-2020, Chef Software Inc.
8
+ #
8
9
 
9
10
  require_relative "../resource"
10
11
 
@@ -21,13 +21,10 @@
21
21
 
22
22
  require_relative "package"
23
23
  require_relative "../provider/package/openbsd"
24
- require_relative "../mixin/shell_out"
25
24
 
26
25
  class Chef
27
26
  class Resource
28
27
  class OpenbsdPackage < Chef::Resource::Package
29
- include Chef::Mixin::ShellOut
30
-
31
28
  resource_name :openbsd_package
32
29
  provides :package, os: "openbsd"
33
30
 
@@ -109,7 +109,7 @@ class Chef
109
109
  end
110
110
 
111
111
  def validate_identity_platform(specified_user, password = nil, specified_domain = nil)
112
- if node[:platform_family] == "windows"
112
+ if windows?
113
113
  if specified_user && password.nil?
114
114
  raise ArgumentError, "A value for `remote_password` must be specified when a value for `user` is specified on the Windows platform"
115
115
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: 2015-2018 Chef Software, Inc.
2
+ # Copyright:: 2015-2020 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +20,7 @@ require_relative "../resource"
20
20
  class Chef
21
21
  class Resource
22
22
  class RhsmErrata < Chef::Resource
23
+ unified_mode true
23
24
  resource_name :rhsm_errata
24
25
  provides(:rhsm_errata) { true }
25
26
 
@@ -36,11 +37,17 @@ class Chef
36
37
  description "Installs a package for a specific errata ID."
37
38
 
38
39
  execute "Install errata packages for #{new_resource.errata_id}" do
39
- command "yum update --advisory #{new_resource.errata_id} -y"
40
+ command "#{package_manager_command} update --advisory #{new_resource.errata_id} -y"
40
41
  default_env true
41
42
  action :run
42
43
  end
43
44
  end
45
+
46
+ action_class do
47
+ def package_manager_command
48
+ node["platform_version"].to_i >= 8 ? "dnf" : "yum"
49
+ end
50
+ end
44
51
  end
45
52
  end
46
53
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: 2015-2018 Chef Software, Inc.
2
+ # Copyright:: 2015-2020 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +20,7 @@ require_relative "../resource"
20
20
  class Chef
21
21
  class Resource
22
22
  class RhsmErrataLevel < Chef::Resource
23
+ unified_mode true
23
24
  resource_name :rhsm_errata_level
24
25
  provides(:rhsm_errata_level) { true }
25
26
 
@@ -35,17 +36,22 @@ class Chef
35
36
  action :install do
36
37
  description "Install all packages of the specified errata level."
37
38
 
38
- yum_package "yum-plugin-security" do
39
- action :install
40
- only_if { node["platform_version"].to_i == 6 }
39
+ if rhel6?
40
+ yum_package "yum-plugin-security"
41
41
  end
42
42
 
43
43
  execute "Install any #{new_resource.errata_level} errata" do
44
- command "yum update --sec-severity=#{new_resource.errata_level.capitalize} -y"
44
+ command "#{package_manager_command} update --sec-severity=#{new_resource.errata_level.capitalize} -y"
45
45
  default_env true
46
46
  action :run
47
47
  end
48
48
  end
49
+
50
+ action_class do
51
+ def package_manager_command
52
+ node["platform_version"].to_i >= 8 ? "dnf" : "yum"
53
+ end
54
+ end
49
55
  end
50
56
  end
51
57
  end