chef 14.1.12 → 14.2.0

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 +1 -6
  3. data/VERSION +1 -1
  4. data/chef.gemspec +2 -3
  5. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +8 -4
  6. data/lib/chef/cookbook/manifest_v0.rb +2 -2
  7. data/lib/chef/cookbook_manifest.rb +3 -2
  8. data/lib/chef/cookbook_version.rb +3 -2
  9. data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -2
  10. data/lib/chef/http/auth_credentials.rb +5 -3
  11. data/lib/chef/http/authenticator.rb +6 -3
  12. data/lib/chef/knife.rb +3 -6
  13. data/lib/chef/knife/configure.rb +12 -8
  14. data/lib/chef/knife/raw.rb +6 -1
  15. data/lib/chef/mixin/shell_out.rb +16 -14
  16. data/lib/chef/provider/execute.rb +4 -3
  17. data/lib/chef/provider/git.rb +1 -1
  18. data/lib/chef/provider/package/dnf.rb +5 -5
  19. data/lib/chef/provider/package/windows.rb +7 -0
  20. data/lib/chef/provider/package/yum.rb +7 -7
  21. data/lib/chef/provider/service/freebsd.rb +3 -3
  22. data/lib/chef/provider/service/init.rb +5 -5
  23. data/lib/chef/provider/service/macosx.rb +5 -4
  24. data/lib/chef/provider/service/simple.rb +4 -4
  25. data/lib/chef/provider/service/systemd.rb +13 -13
  26. data/lib/chef/provider/service/upstart.rb +3 -3
  27. data/lib/chef/provider/service/windows.rb +2 -0
  28. data/lib/chef/provider/systemd_unit.rb +4 -4
  29. data/lib/chef/provider/user.rb +18 -1
  30. data/lib/chef/provider/user/aix.rb +40 -8
  31. data/lib/chef/provider/user/dscl.rb +7 -14
  32. data/lib/chef/provider/user/linux.rb +1 -11
  33. data/lib/chef/provider/user/solaris.rb +57 -26
  34. data/lib/chef/provider/user/useradd.rb +4 -1
  35. data/lib/chef/provider/windows_task.rb +1 -0
  36. data/lib/chef/providers.rb +1 -2
  37. data/lib/chef/resource/execute.rb +4 -1
  38. data/lib/chef/resource/gem_package.rb +1 -1
  39. data/lib/chef/resource/hostname.rb +1 -1
  40. data/lib/chef/resource/sysctl.rb +3 -1
  41. data/lib/chef/resource/windows_ad_join.rb +16 -3
  42. data/lib/chef/resource_inspector.rb +13 -0
  43. data/lib/chef/run_context/cookbook_compiler.rb +1 -1
  44. data/lib/chef/server_api.rb +2 -0
  45. data/lib/chef/version.rb +1 -1
  46. data/spec/functional/mixin/shell_out_spec.rb +27 -1
  47. data/spec/functional/resource/execute_spec.rb +2 -2
  48. data/spec/functional/resource/windows_task_spec.rb +1 -1
  49. data/spec/support/shared/functional/securable_resource.rb +1 -1
  50. data/spec/support/shared/unit/execute_resource.rb +1 -1
  51. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +3 -3
  52. data/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb +65 -0
  53. data/spec/unit/cookbook/manifest_v0_spec.rb +1 -1
  54. data/spec/unit/cookbook_manifest_spec.rb +2 -0
  55. data/spec/unit/dsl/recipe_spec.rb +1 -5
  56. data/spec/unit/http/authenticator_spec.rb +33 -8
  57. data/spec/unit/mixin/shell_out_spec.rb +61 -1
  58. data/spec/unit/provider/apt_update_spec.rb +7 -7
  59. data/spec/unit/provider/execute_spec.rb +16 -15
  60. data/spec/unit/provider/git_spec.rb +3 -3
  61. data/spec/unit/provider/package/windows_spec.rb +12 -0
  62. data/spec/unit/provider/script_spec.rb +2 -2
  63. data/spec/unit/provider/service/arch_service_spec.rb +9 -9
  64. data/spec/unit/provider/service/freebsd_service_spec.rb +6 -6
  65. data/spec/unit/provider/service/init_service_spec.rb +11 -11
  66. data/spec/unit/provider/service/invokercd_service_spec.rb +9 -9
  67. data/spec/unit/provider/service/macosx_spec.rb +11 -11
  68. data/spec/unit/provider/service/openbsd_service_spec.rb +6 -6
  69. data/spec/unit/provider/service/simple_service_spec.rb +4 -4
  70. data/spec/unit/provider/service/systemd_service_spec.rb +16 -16
  71. data/spec/unit/provider/service/upstart_service_spec.rb +12 -12
  72. data/spec/unit/provider/service/windows_spec.rb +5 -0
  73. data/spec/unit/provider/systemd_unit_spec.rb +163 -118
  74. data/spec/unit/provider/user/dscl_spec.rb +2 -9
  75. data/spec/unit/provider/user/solaris_spec.rb +2 -2
  76. data/spec/unit/provider/zypper_repository_spec.rb +3 -3
  77. data/spec/unit/provider_spec.rb +1 -5
  78. data/spec/unit/resource/apt_package_spec.rb +14 -0
  79. data/spec/unit/resource/apt_preference_spec.rb +14 -1
  80. data/spec/unit/resource/apt_repository_spec.rb +12 -3
  81. data/spec/unit/resource/apt_update_spec.rb +9 -0
  82. data/spec/unit/resource/bash_spec.rb +8 -0
  83. data/spec/unit/resource/bff_package_spec.rb +51 -0
  84. data/spec/unit/resource/breakpoint_spec.rb +4 -4
  85. data/spec/unit/resource/build_essential_spec.rb +5 -1
  86. data/spec/unit/resource/cab_package_spec.rb +10 -0
  87. data/spec/unit/resource/chef_gem_spec.rb +14 -0
  88. data/spec/unit/resource/chef_handler_spec.rb +9 -4
  89. data/spec/unit/resource/chocolatey_package_spec.rb +15 -1
  90. data/spec/unit/resource/conditional_spec.rb +3 -3
  91. data/spec/unit/resource/cookbook_file_spec.rb +13 -2
  92. data/spec/unit/resource/cron_spec.rb +2 -7
  93. data/spec/unit/resource/csh_spec.rb +8 -0
  94. data/spec/unit/resource/directory_spec.rb +4 -9
  95. data/spec/unit/resource/dmg_package_spec.rb +8 -4
  96. data/spec/unit/resource/dnf_package_spec.rb +16 -1
  97. data/spec/unit/resource/dpkg_package_spec.rb +18 -0
  98. data/spec/unit/resource/dsc_resource_spec.rb +6 -6
  99. data/spec/unit/resource/dsc_script_spec.rb +39 -39
  100. data/spec/unit/resource/execute_spec.rb +20 -12
  101. data/spec/unit/resource/file_spec.rb +10 -10
  102. data/spec/unit/resource/freebsd_package_spec.rb +16 -0
  103. data/spec/unit/resource/gem_package_spec.rb +27 -0
  104. data/spec/unit/resource/git_spec.rb +17 -2
  105. data/spec/unit/resource/group_spec.rb +18 -17
  106. data/spec/unit/resource/homebrew_cask_spec.rb +9 -4
  107. data/spec/unit/resource/homebrew_package_spec.rb +14 -0
  108. data/spec/unit/resource/homebrew_tap_spec.rb +8 -3
  109. data/spec/unit/resource/hostname_spec.rb +10 -6
  110. data/spec/unit/resource/http_request_spec.rb +14 -0
  111. data/spec/unit/resource/ips_package_spec.rb +15 -3
  112. data/spec/unit/resource/ksh_spec.rb +8 -0
  113. data/spec/unit/resource/launchd_spec.rb +11 -5
  114. data/spec/unit/resource/link_spec.rb +6 -11
  115. data/spec/unit/resource/log_spec.rb +8 -8
  116. data/spec/unit/resource/macos_user_defaults_spec.rb +5 -1
  117. data/spec/unit/resource/macports_package_spec.rb +19 -0
  118. data/spec/unit/resource/mdadm_spec.rb +7 -3
  119. data/spec/unit/resource/mount_spec.rb +15 -18
  120. data/spec/unit/resource/msu_package_spec.rb +10 -0
  121. data/spec/unit/resource/ohai_hint_spec.rb +9 -8
  122. data/spec/unit/resource/ohai_spec.rb +11 -3
  123. data/spec/unit/resource/openbsd_package_spec.rb +14 -0
  124. data/spec/unit/resource/openssl_dhparam.rb +10 -5
  125. data/spec/unit/resource/openssl_rsa_private_key_spec.rb +10 -5
  126. data/spec/unit/resource/openssl_rsa_public_key_spec.rb +9 -5
  127. data/spec/unit/resource/osx_profile_spec.rb +7 -4
  128. data/spec/unit/resource/package_spec.rb +14 -0
  129. data/spec/unit/resource/pacman_package_spec.rb +17 -3
  130. data/spec/unit/resource/paludis_package_spec.rb +36 -0
  131. data/spec/unit/resource/perl_spec.rb +8 -0
  132. data/spec/unit/resource/portage_package_spec.rb +14 -0
  133. data/spec/unit/resource/powershell_package_spec.rb +14 -0
  134. data/spec/unit/resource/python_spec.rb +8 -0
  135. data/spec/unit/resource/reboot_spec.rb +5 -3
  136. data/spec/unit/resource/registry_key_spec.rb +12 -1
  137. data/spec/unit/resource/remote_directory_spec.rb +11 -1
  138. data/spec/unit/resource/remote_file_spec.rb +19 -0
  139. data/spec/unit/resource/rhsm_errata_level_spec.rb +7 -3
  140. data/spec/unit/resource/rhsm_errata_spec.rb +8 -4
  141. data/spec/unit/resource/rhsm_register_spec.rb +6 -1
  142. data/spec/unit/resource/rhsm_repo_spec.rb +9 -4
  143. data/spec/unit/resource/rhsm_subscription_spec.rb +9 -4
  144. data/spec/unit/resource/route_spec.rb +4 -9
  145. data/spec/unit/resource/rpm_package_spec.rb +14 -0
  146. data/spec/unit/resource/ruby_block_spec.rb +12 -8
  147. data/spec/unit/resource/ruby_spec.rb +8 -0
  148. data/spec/unit/resource/scm_spec.rb +16 -8
  149. data/spec/unit/resource/script_spec.rb +8 -0
  150. data/spec/unit/resource/service_spec.rb +15 -0
  151. data/spec/unit/resource/smartos_package_spec.rb +18 -4
  152. data/spec/unit/resource/solaris_package_spec.rb +14 -0
  153. data/spec/unit/resource/subversion_spec.rb +14 -8
  154. data/spec/unit/resource/sudo_spec.rb +11 -4
  155. data/spec/unit/resource/swap_file_spec.rb +4 -5
  156. data/spec/unit/resource/sysctl_spec.rb +8 -10
  157. data/spec/unit/resource/systemd_unit_spec.rb +14 -12
  158. data/spec/unit/resource/template_spec.rb +19 -0
  159. data/spec/unit/resource/{windows_ad_join.rb → windows_ad_join_spec.rb} +12 -6
  160. data/spec/unit/resource/windows_auto_run_spec.rb +9 -9
  161. data/spec/unit/resource/windows_env_spec.rb +8 -16
  162. data/spec/unit/resource/windows_feature.rb +27 -8
  163. data/spec/unit/resource/windows_feature_dism.rb +30 -9
  164. data/spec/unit/resource/windows_feature_powershell.rb +7 -7
  165. data/spec/unit/resource/windows_font_spec.rb +3 -4
  166. data/spec/unit/resource/windows_package_spec.rb +12 -2
  167. data/spec/unit/resource/windows_pagefile_spec.rb +12 -8
  168. data/spec/unit/resource/windows_path_spec.rb +4 -5
  169. data/spec/unit/resource/windows_printer_port_spec.rb +20 -3
  170. data/spec/unit/resource/windows_printer_spec.rb +12 -5
  171. data/spec/unit/resource/windows_service_spec.rb +24 -1
  172. data/spec/unit/resource/windows_shortcut_spec.rb +4 -5
  173. data/spec/unit/resource/yum_repository_spec.rb +48 -2
  174. data/spec/unit/resource/zypper_package_spec.rb +51 -0
  175. data/spec/unit/resource/zypper_repository_spec.rb +56 -11
  176. data/spec/unit/resource_spec.rb +1 -5
  177. metadata +21 -12
  178. data/spec/functional/resource/user/useradd_spec.rb +0 -709
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2016-2017, Chef Software Inc.
2
+ # Copyright:: Copyright 2016-2018, 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");
@@ -85,16 +85,6 @@ class Chef
85
85
  opts
86
86
  end
87
87
 
88
- def should_set?(sym)
89
- current_resource.send(sym).to_s != new_resource.send(sym).to_s && new_resource.send(sym)
90
- end
91
-
92
- def updating_home?
93
- return false unless new_resource.home
94
- return true unless current_resource.home
95
- new_resource.home && Pathname.new(current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath
96
- end
97
-
98
88
  def check_lock
99
89
  # there's an old bug in rhel (https://bugzilla.redhat.com/show_bug.cgi?id=578534)
100
90
  # which means that both 0 and 1 can be success.
@@ -2,7 +2,7 @@
2
2
  # Author:: Stephen Nelson-Smith (<sns@chef.io>)
3
3
  # Author:: Jon Ramsey (<jonathon.ramsey@gmail.com>)
4
4
  # Author:: Dave Eddy (<dave@daveeddy.com>)
5
- # Copyright:: Copyright 2012-2017, Chef Software Inc.
5
+ # Copyright:: Copyright 2012-2018, Chef Software Inc.
6
6
  # Copyright:: Copyright 2015-2016, Dave Eddy
7
7
  # License:: Apache License, Version 2.0
8
8
  #
@@ -18,35 +18,34 @@
18
18
  # See the License for the specific language governing permissions and
19
19
  # limitations under the License.
20
20
 
21
- require "chef/provider/user/useradd"
21
+ require "chef/provider/user"
22
22
 
23
23
  class Chef
24
24
  class Provider
25
25
  class User
26
- class Solaris < Chef::Provider::User::Useradd
26
+ class Solaris < Chef::Provider::User
27
27
  provides :solaris_user
28
- provides :user, os: %w{omnios solaris2}
29
- UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]].freeze
28
+ provides :user, os: %w{openindiana opensolaris illumos omnios solaris2 smartos}
30
29
 
31
- attr_writer :password_file
32
-
33
- def initialize(new_resource, run_context)
34
- @password_file = "/etc/shadow"
35
- super
36
- end
30
+ PASSWORD_FILE = "/etc/shadow"
37
31
 
38
32
  def create_user
39
- super
33
+ shell_out_compact!("useradd", universal_options, useradd_options, new_resource.username)
40
34
  manage_password
41
35
  end
42
36
 
43
37
  def manage_user
44
38
  manage_password
45
- super
39
+ return if universal_options.empty? && usermod_options.empty?
40
+ shell_out_compact!("usermod", universal_options, usermod_options, new_resource.username)
41
+ end
42
+
43
+ def remove_user
44
+ shell_out_compact!("userdel", userdel_options, new_resource.username)
46
45
  end
47
46
 
48
47
  def check_lock
49
- user = IO.read(@password_file).match(/^#{Regexp.escape(new_resource.username)}:([^:]*):/)
48
+ user = IO.read(PASSWORD_FILE).match(/^#{Regexp.escape(new_resource.username)}:([^:]*):/)
50
49
 
51
50
  # If we're in whyrun mode, and the user is not created, we assume it will be
52
51
  return false if whyrun_mode? && user.nil?
@@ -66,15 +65,45 @@ class Chef
66
65
 
67
66
  private
68
67
 
69
- # Override the version from {#Useradd} because Solaris doesn't support
70
- # system users and therefore has no `-r` option. This also inverts the
71
- # logic for manage_home as Solaris defaults to no-manage-home and only
72
- # offers `-m`.
73
- #
74
- # @since 12.15
75
- # @api private
76
- # @see Useradd#useradd_options
77
- # @return [Array<String>]
68
+ def universal_options
69
+ opts = []
70
+ opts << "-c" << new_resource.comment if should_set?(:comment)
71
+ opts << "-g" << new_resource.gid if should_set?(:gid)
72
+ opts << "-s" << new_resource.shell if should_set?(:shell)
73
+ opts << "-u" << new_resource.uid if should_set?(:uid)
74
+ opts << "-d" << new_resource.home if updating_home?
75
+ opts << "-o" if new_resource.non_unique
76
+ if updating_home?
77
+ if new_resource.manage_home
78
+ logger.trace("#{new_resource} managing the users home directory")
79
+ opts << "-m"
80
+ else
81
+ logger.trace("#{new_resource} setting home to #{new_resource.home}")
82
+ end
83
+ end
84
+ opts
85
+ end
86
+
87
+ def usermod_options
88
+ opts = []
89
+ opts += [ "-u", new_resource.uid ] if new_resource.non_unique
90
+ if updating_home?
91
+ if new_resource.manage_home
92
+ opts << "-m"
93
+ end
94
+ end
95
+ opts
96
+ end
97
+
98
+ def userdel_options
99
+ opts = []
100
+ opts << "-r" if new_resource.manage_home
101
+ opts << "-f" if new_resource.force
102
+ opts
103
+ end
104
+
105
+ # Solaris does not support system users and has no '-r' option, solaris also
106
+ # lacks '-M' and defaults to no-manage-home.
78
107
  def useradd_options
79
108
  opts = []
80
109
  opts << "-m" if new_resource.manage_home
@@ -87,9 +116,11 @@ class Chef
87
116
  write_shadow_file
88
117
  end
89
118
 
119
+ # XXX: this was straight copypasta'd back in 2013 and I don't think we've ever evaluted using
120
+ # a pipe to passwd(1) or evaluating modern ruby-shadow. See https://github.com/chef/chef/pull/721
90
121
  def write_shadow_file
91
122
  buffer = Tempfile.new("shadow", "/etc")
92
- ::File.open(@password_file) do |shadow_file|
123
+ ::File.open(PASSWORD_FILE) do |shadow_file|
93
124
  shadow_file.each do |entry|
94
125
  user = entry.split(":").first
95
126
  if user == new_resource.username
@@ -102,7 +133,7 @@ class Chef
102
133
  buffer.close
103
134
 
104
135
  # FIXME: mostly duplicates code with file provider deploying a file
105
- s = ::File.stat(@password_file)
136
+ s = ::File.stat(PASSWORD_FILE)
106
137
  mode = s.mode & 0o7777
107
138
  uid = s.uid
108
139
  gid = s.gid
@@ -110,7 +141,7 @@ class Chef
110
141
  FileUtils.chown uid, gid, buffer.path
111
142
  FileUtils.chmod mode, buffer.path
112
143
 
113
- FileUtils.mv buffer.path, @password_file
144
+ FileUtils.mv buffer.path, PASSWORD_FILE
114
145
  end
115
146
 
116
147
  def updated_password(entry)
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2008-2017, Chef Software Inc.
3
+ # Copyright:: Copyright 2008-2018, 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");
@@ -23,6 +23,9 @@ class Chef
23
23
  class Provider
24
24
  class User
25
25
  class Useradd < Chef::Provider::User
26
+
27
+ Chef::Log.warn("the Chef::Provider::User::Useradd provider is deprecated, please subclass Chef::Provider::User directly")
28
+
26
29
  # the linux version of this has been forked off, this is the base class now of solaris and AIX and should be abandoned
27
30
  # and those provider should be rewritten like the linux version.
28
31
 
@@ -231,6 +231,7 @@ class Chef
231
231
 
232
232
  # seprated command arguments from :command property
233
233
  def set_command_and_arguments
234
+ new_resource.command = new_resource.command.gsub(/\\/, '\&\&')
234
235
  cmd, *args = Shellwords.split(new_resource.command)
235
236
  new_resource.command = cmd
236
237
  new_resource.command_arguments = args.join(" ")
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Daniel DeLeo (<dan@chef.io>)
3
- # Copyright:: Copyright 2010-2016, Chef Software, Inc.
3
+ # Copyright:: Copyright 2010-2018, 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");
@@ -109,7 +109,6 @@ require "chef/provider/user/dscl"
109
109
  require "chef/provider/user/linux"
110
110
  require "chef/provider/user/pw"
111
111
  require "chef/provider/user/solaris"
112
- require "chef/provider/user/useradd"
113
112
  require "chef/provider/user/windows"
114
113
 
115
114
  require "chef/provider/group/aix"
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Tyler Cloke (<tyler@chef.io>)
4
- # Copyright:: Copyright 2008-2017, Chef Software Inc.
4
+ # Copyright:: Copyright 2008-2018, 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");
@@ -64,6 +64,9 @@ class Chef
64
64
 
65
65
  property :group, [ String, Integer ]
66
66
  property :live_stream, [ TrueClass, FalseClass ], default: false
67
+ # default_env defaults to `false` so that the command execution more exactly matches what the user gets on the command line without magic
68
+ property :default_env, [ TrueClass, FalseClass ], desired_state: false, default: false,
69
+ description: "When true this enables ENV magic to add path_sanity to the PATH and force the locale to English+UTF-8 for parsing output"
67
70
  property :returns, [ Integer, Array ], default: 0
68
71
  property :timeout, [ Integer, Float ]
69
72
  property :user, [ String, Integer ]
@@ -40,7 +40,7 @@ class Chef
40
40
  # FIXME? the array form of installing paths most likely does not work?
41
41
  #
42
42
  property :source, [ String, Array ]
43
- property :clear_sources, [ TrueClass, FalseClass ], default: false, desired_state: false
43
+ property :clear_sources, [ TrueClass, FalseClass ], default: lazy { Chef::Config[:clear_gem_sources] }, desired_state: false
44
44
  # Sets a custom gem_binary to run for gem commands.
45
45
  property :gem_binary, String, desired_state: false
46
46
 
@@ -116,7 +116,7 @@ class Chef
116
116
  # this must come before other methods like /etc/hostname and /etc/sysconfig/network
117
117
  declare_resource(:execute, "hostnamectl set-hostname #{new_resource.hostname}") do
118
118
  notifies :reload, "ohai[reload hostname]"
119
- not_if { shell_out!("hostnamectl status", { :returns => [0, 1] }).stdout =~ /Static hostname:\s+#{new_resource.hostname}/ }
119
+ not_if { shell_out!("hostnamectl status", { :returns => [0, 1] }).stdout =~ /Static hostname:\s*#{new_resource.hostname}\s*$/ }
120
120
  end
121
121
  when ::File.exist?("/etc/hostname")
122
122
  # debian family uses /etc/hostname
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Copyright:: 2018, Webb Agile Solutions Ltd.
3
- # Copyright:: 2018, Chef Software Inc.
3
+ # Copyright:: 2018-2018, Chef Software Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -84,6 +84,7 @@ class Chef
84
84
 
85
85
  execute "Load sysctl values" do
86
86
  command "sysctl #{'-e ' if new_resource.ignore_error}-p"
87
+ default_env true
87
88
  action :run
88
89
  end
89
90
  end
@@ -98,6 +99,7 @@ class Chef
98
99
  end
99
100
 
100
101
  execute "Load sysctl values" do
102
+ default_env true
101
103
  command "sysctl -p"
102
104
  action :run
103
105
  end
@@ -47,7 +47,7 @@ class Chef
47
47
  description: "The path to the OU where you would like to place the host."
48
48
 
49
49
  property :reboot, Symbol,
50
- equal_to: [:immediate, :delayed, :never],
50
+ equal_to: [:immediate, :delayed, :never, :request_reboot, :reboot_now],
51
51
  validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the Chef run completes), and :never (Don't reboot)",
52
52
  description: "Controls the system reboot behavior post domain joining. Reboot immediately, after the Chef run completes, or never. Note that a reboot is necessary for changes to take effect.",
53
53
  default: :immediate
@@ -71,8 +71,8 @@ class Chef
71
71
  raise "Failed to join the domain #{new_resource.domain_name}: #{ps_run.stderr}}" if ps_run.error?
72
72
 
73
73
  unless new_resource.reboot == :never
74
- declare_resource(:reboot, "Reboot to join domain #{new_resource.domain_name}") do
75
- action new_resource.reboot
74
+ reboot "Reboot to join domain #{new_resource.domain_name}" do
75
+ action clarify_reboot(new_resource.reboot)
76
76
  reason "Reboot to join domain #{new_resource.domain_name}"
77
77
  end
78
78
  end
@@ -86,6 +86,19 @@ class Chef
86
86
  raise "Failed to check if the system is joined to the domain #{new_resource.domain_name}: #{node_domain.stderr}}" if node_domain.error?
87
87
  node_domain.stdout.downcase.strip == new_resource.domain_name.downcase
88
88
  end
89
+
90
+ # This resource historically took `:immediate` and `:delayed` as arguments to the reboot property but then
91
+ # tried to shove that straight to the `reboot` resource which objected strenuously
92
+ def clarify_reboot(reboot_action)
93
+ case reboot_action
94
+ when :immediate
95
+ :reboot_now
96
+ when :delayed
97
+ :request_reboot
98
+ else
99
+ reboot_action
100
+ end
101
+ end
89
102
  end
90
103
  end
91
104
  end
@@ -24,10 +24,22 @@ require "chef/resources"
24
24
  require "chef/json_compat"
25
25
 
26
26
  module ResourceInspector
27
+ def self.get_default(default)
28
+ if default.kind_of?(Chef::DelayedEvaluator)
29
+ # ideally we'd get the block we pass to `lazy`, but the best we can do
30
+ # is to get the source location, which then results in reparsing the source
31
+ # code for the resource ourselves and just no
32
+ "lazy default"
33
+ else
34
+ default
35
+ end
36
+ end
37
+
27
38
  def self.extract_resource(resource, complete = false)
28
39
  data = {}
29
40
  data[:description] = resource.description
30
41
  # data[:deprecated] = resource.deprecated || false
42
+ data[:default_action] = resource.default_action
31
43
  data[:actions] = resource.allowed_actions
32
44
  data[:examples] = resource.examples
33
45
  data[:introduced] = resource.introduced
@@ -43,6 +55,7 @@ module ResourceInspector
43
55
  acc << { name: n, description: opts[:description],
44
56
  introduced: opts[:introduced], is: opts[:is],
45
57
  deprecated: opts[:deprecated] || false,
58
+ default: get_default(opts[:default]),
46
59
  name_property: opts[:name_property] || false }
47
60
  end
48
61
  data
@@ -191,7 +191,7 @@ class Chef
191
191
 
192
192
  def load_attributes_from_cookbook(cookbook_name)
193
193
  list_of_attr_files = files_in_cookbook_by_segment(cookbook_name, :attributes).dup
194
- root_alias = cookbook_collection[cookbook_name].files_for(:root_files).find { |record| record[:name] == "attributes.rb" }
194
+ root_alias = cookbook_collection[cookbook_name].files_for(:root_files).find { |record| record[:name] == "root_files/attributes.rb" }
195
195
  default_file = list_of_attr_files.find { |path| File.basename(path) == "default.rb" }
196
196
  if root_alias
197
197
  if default_file
@@ -30,9 +30,11 @@ class Chef
30
30
  class ServerAPI < Chef::HTTP
31
31
 
32
32
  def initialize(url = Chef::Config[:chef_server_url], options = {})
33
+ # # If making a change here, also update Chef::Knife::Raw::RawInputServerAPI.
33
34
  options[:client_name] ||= Chef::Config[:node_name]
34
35
  options[:raw_key] ||= Chef::Config[:client_key_contents]
35
36
  options[:signing_key_filename] ||= Chef::Config[:client_key] unless options[:raw_key]
37
+ options[:ssh_agent_signing] ||= Chef::Config[:ssh_agent_signing]
36
38
  options[:signing_key_filename] = nil if chef_zero_uri?(url)
37
39
  options[:inflate_json_class] = false
38
40
  super(url, options)
@@ -23,7 +23,7 @@ require "chef/version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("14.1.12")
26
+ VERSION = Chef::VersionString.new("14.2.0")
27
27
  end
28
28
 
29
29
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2014-2016, Chef Software, Inc.
2
+ # Copyright:: Copyright 2014-2018, 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");
@@ -45,4 +45,30 @@ describe Chef::Mixin::ShellOut do
45
45
  end
46
46
  end
47
47
  end
48
+
49
+ describe "shell_out default_env: false" do
50
+ describe "when environment['LC_ALL'] is not set" do
51
+ it "should use the default shell_out setting" do
52
+ cmd = if windows?
53
+ shell_out("echo %LC_ALL%", default_env: false)
54
+ else
55
+ shell_out("echo $LC_ALL", default_env: false)
56
+ end
57
+
58
+ expect(cmd.stdout.chomp).to match_environment_variable("LC_ALL")
59
+ end
60
+ end
61
+
62
+ describe "when environment['LC_ALL'] is set" do
63
+ it "should use the option's setting" do
64
+ cmd = if windows?
65
+ shell_out("echo %LC_ALL%", :environment => { "LC_ALL" => "POSIX" }, default_env: false)
66
+ else
67
+ shell_out("echo $LC_ALL", :environment => { "LC_ALL" => "POSIX" }, default_env: false)
68
+ end
69
+
70
+ expect(cmd.stdout.chomp).to eq "POSIX"
71
+ end
72
+ end
73
+ end
48
74
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Serdar Sutay (<serdar@chef.io>)
3
- # Copyright:: Copyright 2014-2017, Chef Software Inc.
3
+ # Copyright:: Copyright 2014-2018, 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");
@@ -51,7 +51,7 @@ describe Chef::Resource::Execute do
51
51
 
52
52
  # why_run mode doesn't disable the updated_by_last_action logic, so we really have to look at the provider action
53
53
  # to see if why_run correctly disabled the resource. It should shell_out! for the guard but not the resource.
54
- expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out_with_systems_locale!).once
54
+ expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).once
55
55
 
56
56
  resource.only_if guard
57
57
  resource.run_action(:run)
@@ -68,7 +68,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
68
68
  current_resource = call_for_load_current_resource
69
69
  expect(current_resource.exists).to eq(true)
70
70
  expect(current_resource.task.application_name).to eq("chef-client")
71
- expect(current_resource.task.parameters).to eq("-W -L C:\\chef\\chef-ad-join.log")
71
+ expect(current_resource.task.parameters).to eq("-W -L C:\\\\chef\\\\chef-ad-join.log")
72
72
  end
73
73
 
74
74
  it "does not converge the resource if it is already converged" do
@@ -313,7 +313,7 @@ shared_examples_for "a securable resource without existing target" do
313
313
  end
314
314
 
315
315
  it "sets owner when owner is specified with a \\" do
316
- resource.owner "#{ENV['USERDOMAIN']}\\Guest"
316
+ resource.owner "#{ENV['COMPUTERNAME']}\\Guest"
317
317
  resource.run_action(:create)
318
318
  expect(descriptor.owner).to eq(SID.Guest)
319
319
  end