chef 15.3.14 → 15.4.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/chef.gemspec +2 -2
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/event_dispatch/dispatcher.rb +9 -2
- data/lib/chef/formatters/doc.rb +3 -3
- data/lib/chef/knife.rb +13 -3
- data/lib/chef/knife/bootstrap.rb +28 -4
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +7 -8
- data/lib/chef/knife/data_bag_secret_options.rb +11 -4
- data/lib/chef/knife/download.rb +2 -2
- data/lib/chef/knife/exec.rb +9 -1
- data/lib/chef/knife/ssh.rb +1 -1
- data/lib/chef/knife/ssl_check.rb +1 -1
- data/lib/chef/knife/supermarket_list.rb +19 -7
- data/lib/chef/knife/supermarket_search.rb +3 -2
- data/lib/chef/node/attribute.rb +2 -0
- data/lib/chef/node/attribute_collections.rb +8 -0
- data/lib/chef/node/immutable_collections.rb +12 -0
- data/lib/chef/node/mixin/immutablize_array.rb +1 -0
- data/lib/chef/node/mixin/immutablize_hash.rb +1 -0
- data/lib/chef/provider.rb +14 -8
- data/lib/chef/provider/package/chocolatey.rb +11 -3
- data/lib/chef/provider/package/dnf/python_helper.rb +8 -3
- data/lib/chef/provider/package/windows/exe.rb +2 -2
- data/lib/chef/provider/package/windows/msi.rb +3 -3
- data/lib/chef/provider/package/yum/python_helper.rb +8 -3
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/resource/apt_repository.rb +19 -13
- data/lib/chef/resource/apt_update.rb +15 -1
- data/lib/chef/resource/archive_file.rb +10 -1
- data/lib/chef/resource/build_essential.rb +14 -1
- data/lib/chef/resource/chocolatey_config.rb +17 -1
- data/lib/chef/resource/chocolatey_feature.rb +15 -0
- data/lib/chef/resource/chocolatey_package.rb +31 -1
- data/lib/chef/resource/chocolatey_source.rb +17 -1
- data/lib/chef/resource/cookbook_file.rb +1 -1
- data/lib/chef/resource/cron_access.rb +22 -1
- data/lib/chef/resource/cron_d.rb +46 -1
- data/lib/chef/resource/dmg_package.rb +28 -0
- data/lib/chef/resource/kernel_module.rb +61 -0
- data/lib/chef/resource/sudo.rb +2 -2
- data/lib/chef/resource/windows_ad_join.rb +72 -3
- data/lib/chef/resource/windows_service.rb +1 -1
- data/lib/chef/resource/windows_share.rb +2 -1
- data/lib/chef/shell.rb +4 -4
- data/lib/chef/shell/ext.rb +2 -2
- data/lib/chef/train_transport.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/ifconfig_spec.rb +0 -2
- data/spec/functional/resource/mount_spec.rb +0 -4
- data/spec/functional/util/powershell/cmdlet_spec.rb +2 -2
- data/spec/integration/knife/chef_repo_path_spec.rb +4 -2
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +19 -19
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/formatters/doc_spec.rb +18 -0
- data/spec/unit/knife/bootstrap_spec.rb +46 -10
- data/spec/unit/knife/supermarket_list_spec.rb +70 -0
- data/spec/unit/knife/supermarket_search_spec.rb +85 -0
- data/spec/unit/node/attribute_spec.rb +22 -0
- data/spec/unit/node/immutable_collections_spec.rb +72 -144
- data/spec/unit/provider/package/chocolatey_spec.rb +50 -35
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/service/windows_spec.rb +23 -3
- data/spec/unit/resource/chocolatey_package_spec.rb +17 -2
- data/spec/unit/resource/windows_ad_join_spec.rb +4 -0
- data/spec/unit/resource/windows_service_spec.rb +5 -0
- data/spec/unit/resource/windows_share_spec.rb +7 -0
- data/tasks/docs.rb +4 -1
- metadata +10 -8
data/lib/chef/resource/cron_d.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: 2008-
|
2
|
+
# Copyright:: 2008-2019, 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");
|
@@ -26,6 +26,51 @@ class Chef
|
|
26
26
|
|
27
27
|
introduced "14.4"
|
28
28
|
description "Use the cron_d resource to manage cron definitions in /etc/cron.d. This is similar to the 'cron' resource, but it does not use the monolithic /etc/crontab file."
|
29
|
+
examples <<~DOC
|
30
|
+
To run a program on the fifth hour of the day
|
31
|
+
```ruby
|
32
|
+
cron_d 'noop' do
|
33
|
+
hour '5'
|
34
|
+
minute '0'
|
35
|
+
command '/bin/true'
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
To run an entry if a folder exists
|
40
|
+
```ruby
|
41
|
+
cron_d 'ganglia_tomcat_thread_max' do
|
42
|
+
command "/usr/bin/gmetric
|
43
|
+
-n 'tomcat threads max'
|
44
|
+
-t uint32
|
45
|
+
-v '/usr/local/bin/tomcat-stat
|
46
|
+
--thread-max'"
|
47
|
+
only_if { ::File.exist?('/home/jboss') }
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
To run an entry every Saturday, 8:00 AM
|
52
|
+
```ruby
|
53
|
+
cron_d 'name_of_cron_entry' do
|
54
|
+
minute '0'
|
55
|
+
hour '8'
|
56
|
+
weekday '6'
|
57
|
+
mailto 'admin@example.com'
|
58
|
+
action :create
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
To run an entry at 8:00 PM, every weekday (Monday through Friday), but only in November
|
63
|
+
```ruby
|
64
|
+
cron_d 'name_of_cron_entry' do
|
65
|
+
minute '0'
|
66
|
+
hour '20'
|
67
|
+
day '*'
|
68
|
+
month '11'
|
69
|
+
weekday '1-5'
|
70
|
+
action :create
|
71
|
+
end
|
72
|
+
```
|
73
|
+
DOC
|
29
74
|
|
30
75
|
# validate a provided value is between two other provided values
|
31
76
|
# we also allow * as a valid input
|
@@ -25,6 +25,34 @@ class Chef
|
|
25
25
|
|
26
26
|
description "Use the dmg_package resource to install a dmg 'package'. The resource will retrieve the dmg file from a remote URL, mount it using OS X's hdidutil, copy the application (.app directory) to the specified destination (/Applications), and detach the image using hdiutil. The dmg file will be stored in the Chef::Config[:file_cache_path]."
|
27
27
|
introduced "14.0"
|
28
|
+
examples <<~DOC
|
29
|
+
Install Google Chrome via the DMG package
|
30
|
+
```ruby
|
31
|
+
dmg_package 'Google Chrome' do
|
32
|
+
dmg_name 'googlechrome'
|
33
|
+
source 'https://dl-ssl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg'
|
34
|
+
checksum '7daa2dc5c46d9bfb14f1d7ff4b33884325e5e63e694810adc58f14795165c91a'
|
35
|
+
action :install
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
Install Virtualbox from the .mpkg
|
40
|
+
```ruby
|
41
|
+
dmg_package 'Virtualbox' do
|
42
|
+
source 'http://dlc.sun.com.edgesuite.net/virtualbox/4.0.8/VirtualBox-4.0.8-71778-OSX.dmg'
|
43
|
+
type 'mpkg'
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
Install pgAdmin and automatically accept the EULA
|
48
|
+
```ruby
|
49
|
+
dmg_package 'pgAdmin3' do
|
50
|
+
source 'http://wwwmaster.postgresql.org/redir/198/h/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg'
|
51
|
+
checksum '9435f79d5b52d0febeddfad392adf82db9df159196f496c1ab139a6957242ce9'
|
52
|
+
accept_eula true
|
53
|
+
end
|
54
|
+
```
|
55
|
+
DOC
|
28
56
|
|
29
57
|
property :app, String,
|
30
58
|
description: "The name of the application as it appears in the /Volumes directory if it differs from the resource block's name.",
|
@@ -15,11 +15,61 @@ class Chef
|
|
15
15
|
|
16
16
|
description "Use the kernel_module resource to manage kernel modules on Linux systems. This resource can load, unload, blacklist, disable, install, and uninstall modules."
|
17
17
|
introduced "14.3"
|
18
|
+
examples <<~DOC
|
19
|
+
Install and load a kernel module, and ensure it loads on reboot.
|
20
|
+
```ruby
|
21
|
+
kernel_module 'loop'
|
22
|
+
```
|
23
|
+
Install and load a kernel with a specific set of options, and ensure it loads on reboot. Consult kernel module
|
24
|
+
documentation for specific options that are supported.
|
25
|
+
```ruby
|
26
|
+
kernel_module 'loop' do
|
27
|
+
options [
|
28
|
+
'max_loop=4',
|
29
|
+
'max_part=8'
|
30
|
+
]
|
31
|
+
end
|
32
|
+
```
|
33
|
+
Load a kernel module.
|
34
|
+
```ruby
|
35
|
+
kernel_module 'loop' do
|
36
|
+
action :load
|
37
|
+
end
|
38
|
+
```
|
39
|
+
Unload a kernel module and remove module config, so it doesn’t load on reboot.
|
40
|
+
```ruby
|
41
|
+
kernel_module 'loop' do
|
42
|
+
action :uninstall
|
43
|
+
end
|
44
|
+
```
|
45
|
+
Unload kernel module.
|
46
|
+
```ruby
|
47
|
+
kernel_module 'loop' do
|
48
|
+
action :unload
|
49
|
+
end
|
50
|
+
```
|
51
|
+
Blacklist a module from loading.
|
52
|
+
```ruby
|
53
|
+
kernel_module 'loop' do
|
54
|
+
action :blacklist
|
55
|
+
end
|
56
|
+
```
|
57
|
+
Disable a kernel module.
|
58
|
+
```ruby
|
59
|
+
kernel_module 'loop' do
|
60
|
+
action :disable
|
61
|
+
end
|
62
|
+
```
|
63
|
+
DOC
|
18
64
|
|
19
65
|
property :modname, String,
|
20
66
|
description: "An optional property to set the kernel module name if it differs from the resource block's name.",
|
21
67
|
name_property: true, identity: true
|
22
68
|
|
69
|
+
property :options, Array,
|
70
|
+
description: "An optional property to set options for the kernel module.",
|
71
|
+
introduced: "15.4"
|
72
|
+
|
23
73
|
property :load_dir, String,
|
24
74
|
description: "The directory to load modules from.",
|
25
75
|
default: "/etc/modules-load.d"
|
@@ -31,6 +81,13 @@ class Chef
|
|
31
81
|
action :install do
|
32
82
|
description "Load kernel module, and ensure it loads on reboot."
|
33
83
|
|
84
|
+
# create options file before loading the module
|
85
|
+
unless new_resource.options.nil?
|
86
|
+
file "#{new_resource.unload_dir}/options_#{new_resource.modname}.conf" do
|
87
|
+
content "options #{new_resource.modname} #{new_resource.options.join(" ")}\n"
|
88
|
+
end.run_action(:create)
|
89
|
+
end
|
90
|
+
|
34
91
|
# load the module first before installing
|
35
92
|
new_resource.run_action(:load)
|
36
93
|
|
@@ -64,6 +121,10 @@ class Chef
|
|
64
121
|
notifies :run, "execute[update initramfs]", :delayed
|
65
122
|
end
|
66
123
|
|
124
|
+
file "#{new_resource.unload_dir}/options_#{new_resource.modname}.conf" do
|
125
|
+
action :delete
|
126
|
+
end
|
127
|
+
|
67
128
|
with_run_context :root do
|
68
129
|
find_resource(:execute, "update initramfs") do
|
69
130
|
command initramfs_command
|
data/lib/chef/resource/sudo.rb
CHANGED
@@ -166,7 +166,7 @@ class Chef
|
|
166
166
|
source new_resource.template
|
167
167
|
mode "0440"
|
168
168
|
variables new_resource.variables
|
169
|
-
verify "#{new_resource.visudo_binary} -cf
|
169
|
+
verify "cat #{new_resource.config_prefix}/sudoers %{path} | #{new_resource.visudo_binary} -cf -" if visudo_present?
|
170
170
|
action :create
|
171
171
|
end
|
172
172
|
else
|
@@ -185,7 +185,7 @@ class Chef
|
|
185
185
|
setenv: new_resource.setenv,
|
186
186
|
env_keep_add: new_resource.env_keep_add,
|
187
187
|
env_keep_subtract: new_resource.env_keep_subtract
|
188
|
-
verify "#{new_resource.visudo_binary} -cf
|
188
|
+
verify "cat #{new_resource.config_prefix}/sudoers %{path} | #{new_resource.visudo_binary} -cf -" if visudo_present?
|
189
189
|
action :create
|
190
190
|
end
|
191
191
|
end
|
@@ -57,6 +57,10 @@ class Chef
|
|
57
57
|
description: "Specifies a new hostname for the computer in the new domain.",
|
58
58
|
introduced: "14.5"
|
59
59
|
|
60
|
+
property :workgroup_name, String,
|
61
|
+
description: "Specifies the name of a workgroup to which the computer is added to when it is removed from the domain. The default value is WORKGROUP. This property is only applicable to the :leave action.",
|
62
|
+
introduced: "15.0"
|
63
|
+
|
60
64
|
# define this again so we can default it to true. Otherwise failures print the password
|
61
65
|
property :sensitive, [TrueClass, FalseClass],
|
62
66
|
default: true, desired_state: false
|
@@ -64,7 +68,7 @@ class Chef
|
|
64
68
|
action :join do
|
65
69
|
description "Join the Active Directory domain."
|
66
70
|
|
67
|
-
unless
|
71
|
+
unless on_desired_domain?
|
68
72
|
cmd = "$pswd = ConvertTo-SecureString \'#{new_resource.domain_password}\' -AsPlainText -Force;"
|
69
73
|
cmd << "$credential = New-Object System.Management.Automation.PSCredential (\"#{new_resource.domain_user}@#{new_resource.domain_name}\",$pswd);"
|
70
74
|
cmd << "Add-Computer -DomainName #{new_resource.domain_name} -Credential $credential"
|
@@ -92,12 +96,77 @@ class Chef
|
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
99
|
+
action :leave do
|
100
|
+
description "Leave the Active Directory domain."
|
101
|
+
|
102
|
+
if joined_to_domain?
|
103
|
+
cmd = ""
|
104
|
+
cmd << "$pswd = ConvertTo-SecureString \'#{new_resource.domain_password}\' -AsPlainText -Force;"
|
105
|
+
cmd << "$credential = New-Object System.Management.Automation.PSCredential (\"#{new_resource.domain_user}@#{new_resource.domain_name}\",$pswd);"
|
106
|
+
cmd << "Remove-Computer"
|
107
|
+
cmd << " -UnjoinDomainCredential $credential"
|
108
|
+
cmd << " -NewName \"#{new_resource.new_hostname}\"" if new_resource.new_hostname
|
109
|
+
cmd << " -WorkgroupName \"#{new_resource.workgroup_name}\"" if new_resource.workgroup_name
|
110
|
+
cmd << " -Force"
|
111
|
+
|
112
|
+
converge_by("leave Active Directory domain #{node_domain}") do
|
113
|
+
ps_run = powershell_out(cmd)
|
114
|
+
if ps_run.error?
|
115
|
+
if sensitive?
|
116
|
+
raise "Failed to leave the domain #{node_domain}: *suppressed sensitive resource output*"
|
117
|
+
else
|
118
|
+
raise "Failed to leave the domain #{node_domain}: #{ps_run.stderr}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
unless new_resource.reboot == :never
|
123
|
+
reboot "Reboot to leave domain #{new_resource.domain_name}" do
|
124
|
+
action clarify_reboot(new_resource.reboot)
|
125
|
+
reason "Reboot to leave domain #{new_resource.domain_name}"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
95
132
|
action_class do
|
96
|
-
|
133
|
+
#
|
134
|
+
# @return [String] The domain name the node is joined to. When the node
|
135
|
+
# is not joined to a domain this will return the name of the
|
136
|
+
# workgroup the node is a member of.
|
137
|
+
#
|
138
|
+
def node_domain
|
97
139
|
node_domain = powershell_out!("(Get-WmiObject Win32_ComputerSystem).Domain")
|
98
140
|
raise "Failed to check if the system is joined to the domain #{new_resource.domain_name}: #{node_domain.stderr}}" if node_domain.error?
|
99
141
|
|
100
|
-
node_domain.stdout.downcase.strip
|
142
|
+
node_domain.stdout.downcase.strip
|
143
|
+
end
|
144
|
+
|
145
|
+
#
|
146
|
+
# @return [String] The workgroup the node is a member of. This will
|
147
|
+
# return an empty string if the system is not a member of a
|
148
|
+
# workgroup.
|
149
|
+
#
|
150
|
+
def node_workgroup
|
151
|
+
node_workgroup = powershell_out!("(Get-WmiObject Win32_ComputerSystem).Workgroup")
|
152
|
+
raise "Failed to check if the system is currently a member of a workgroup" if node_workgroup.error?
|
153
|
+
|
154
|
+
node_workgroup.stdout.downcase.strip
|
155
|
+
end
|
156
|
+
|
157
|
+
#
|
158
|
+
# @return [true, false] Whether or not the node is joined to ANY domain
|
159
|
+
#
|
160
|
+
def joined_to_domain?
|
161
|
+
node_workgroup.empty? && !node_domain.empty?
|
162
|
+
end
|
163
|
+
|
164
|
+
#
|
165
|
+
# @return [true, false] Whether or not the node is joined to the domain
|
166
|
+
# defined by the resource :domain_name property.
|
167
|
+
#
|
168
|
+
def on_desired_domain?
|
169
|
+
node_domain == new_resource.domain_name.downcase
|
101
170
|
end
|
102
171
|
|
103
172
|
# This resource historically took `:immediate` and `:delayed` as arguments to the reboot property but then
|
@@ -108,7 +108,7 @@ class Chef
|
|
108
108
|
description: "Description of the service.",
|
109
109
|
introduced: "14.0"
|
110
110
|
|
111
|
-
property :run_as_user, String, default: "
|
111
|
+
property :run_as_user, String, default: "localsystem", coerce: proc { |x| x.downcase }
|
112
112
|
property :run_as_password, String, default: ""
|
113
113
|
end
|
114
114
|
end
|
@@ -38,7 +38,8 @@ class Chef
|
|
38
38
|
|
39
39
|
# Specifies the path of the location of the folder to share. The path must be fully qualified. Relative paths or paths that contain wildcard characters are not permitted.
|
40
40
|
property :path, String,
|
41
|
-
description: "The path of the folder to share. Required when creating. If the share already exists on a different path then it is deleted and re-created."
|
41
|
+
description: "The path of the folder to share. Required when creating. If the share already exists on a different path then it is deleted and re-created.",
|
42
|
+
coerce: proc { |p| p.gsub!(%r{/}, "\\") || p }
|
42
43
|
|
43
44
|
# Specifies an optional description of the SMB share. A description of the share is displayed by running the Get-SmbShare cmdlet. The description may not contain more than 256 characters.
|
44
45
|
property :description, String,
|
data/lib/chef/shell.rb
CHANGED
@@ -121,11 +121,11 @@ module Shell
|
|
121
121
|
irb_conf[:IRB_RC] = lambda do |conf|
|
122
122
|
m = conf.main
|
123
123
|
|
124
|
-
conf.prompt_c = "
|
124
|
+
conf.prompt_c = "#{Chef::Dist::EXEC}#{leader(m)} > "
|
125
125
|
conf.return_format = " => %s \n"
|
126
|
-
conf.prompt_i = "
|
127
|
-
conf.prompt_n = "
|
128
|
-
conf.prompt_s = "
|
126
|
+
conf.prompt_i = "#{Chef::Dist::EXEC}#{leader(m)} (#{Chef::VERSION})> "
|
127
|
+
conf.prompt_n = "#{Chef::Dist::EXEC}#{leader(m)} ?> "
|
128
|
+
conf.prompt_s = "#{Chef::Dist::EXEC}#{leader(m)}%l> "
|
129
129
|
conf.use_tracer = false
|
130
130
|
end
|
131
131
|
end
|
data/lib/chef/shell/ext.rb
CHANGED
@@ -211,8 +211,8 @@ module Shell
|
|
211
211
|
desc "prints information about chef"
|
212
212
|
def version
|
213
213
|
puts "This is the #{Chef::Dist::SHELL}.\n" +
|
214
|
-
" Chef Version: #{::Chef::VERSION}\n" +
|
215
|
-
"
|
214
|
+
" #{Chef::Dist::PRODUCT} Version: #{::Chef::VERSION}\n" +
|
215
|
+
" #{Chef::Dist::WEBSITE}\n" +
|
216
216
|
" https://docs.chef.io/"
|
217
217
|
:ucanhaz_automation
|
218
218
|
end
|
data/lib/chef/train_transport.rb
CHANGED
@@ -100,7 +100,7 @@ class Chef
|
|
100
100
|
tm_config = Chef::Config.target_mode
|
101
101
|
protocol = tm_config.protocol
|
102
102
|
train_config = tm_config.to_hash.select { |k| Train.options(protocol).key?(k) }
|
103
|
-
Chef::Log.trace("Using target mode options from Chef config file: #{train_config.keys.join(", ")}") if train_config
|
103
|
+
Chef::Log.trace("Using target mode options from #{Chef::Dist::PRODUCT} config file: #{train_config.keys.join(", ")}") if train_config
|
104
104
|
|
105
105
|
# Load the credentials file, and place any valid settings into the train configuration
|
106
106
|
credentials = load_credentials(tm_config.host)
|
data/lib/chef/version.rb
CHANGED
@@ -24,8 +24,6 @@ require "chef/mixin/shell_out"
|
|
24
24
|
include_flag = !(%w{amazon debian aix}.include?(ohai[:platform_family]) || (ohai[:platform_family] == "rhel" && ohai[:platform_version].to_i < 7))
|
25
25
|
|
26
26
|
describe Chef::Resource::Ifconfig, :requires_root, external: include_flag do
|
27
|
-
# This test does not work in travis because there is no eth0
|
28
|
-
|
29
27
|
include Chef::Mixin::ShellOut
|
30
28
|
|
31
29
|
let(:new_resource) do
|
@@ -25,13 +25,9 @@ require "tmpdir"
|
|
25
25
|
include_flag = !(%w{debian rhel amazon aix solaris2}.include?(ohai[:platform_family]))
|
26
26
|
|
27
27
|
describe Chef::Resource::Mount, :requires_root, external: include_flag do
|
28
|
-
# Disabled in travis because it refuses to let us mount a ramdisk. /dev/ramX does not
|
29
|
-
# exist even after loading the kernel module
|
30
|
-
|
31
28
|
include Chef::Mixin::ShellOut
|
32
29
|
|
33
30
|
# Platform specific setup, cleanup and validation helpers.
|
34
|
-
|
35
31
|
def setup_device_for_mount
|
36
32
|
# use ramdisk for creating a test device for mount.
|
37
33
|
# This can cleaner if we have chef resource/provider for ramdisk.
|
@@ -88,7 +88,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
|
|
88
88
|
it "returns json format data" do
|
89
89
|
result = cmdlet_alias_requires_switch_or_argument.run({}, {}, "ls")
|
90
90
|
expect(result.succeeded?).to eq(true)
|
91
|
-
expect
|
91
|
+
expect { Chef::JSONCompat.parse(result.return_value) }.not_to raise_error
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -105,7 +105,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
|
|
105
105
|
context "when constructor is given invalid arguments" do
|
106
106
|
let(:cmd_output_format) { :invalid }
|
107
107
|
it "throws an exception if an invalid format is passed to the constructor" do
|
108
|
-
expect
|
108
|
+
expect { simple_cmdlet }.to raise_error(ArgumentError)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
@@ -79,7 +79,8 @@ describe "chef_repo_path tests", :workstation do
|
|
79
79
|
EOM
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
# "Skipping for BK... As Windows 2019 has 8dot3name disabled by default"
|
83
|
+
it "knife list --local -Rfp --chef-repo-path chef_r~1 / grabs chef_repo2 stuff", :windows_only, :skip_buildkite do
|
83
84
|
Chef::Config.delete(:chef_repo_path)
|
84
85
|
knife("list --local -Rfp --chef-repo-path #{path_to("chef_r~1")} /").should_succeed <<~EOM
|
85
86
|
/clients/
|
@@ -101,7 +102,8 @@ describe "chef_repo_path tests", :workstation do
|
|
101
102
|
EOM
|
102
103
|
end
|
103
104
|
|
104
|
-
|
105
|
+
# "Skipping for BK... As Windows 2019 has 8dot3name disabled by default"
|
106
|
+
it "knife list --local -Rfp --chef-repo-path chef_r~1 / grabs chef_repo2 stuff", :windows_only, :skip_buildkite do
|
105
107
|
Chef::Config.delete(:chef_repo_path)
|
106
108
|
knife("list -z -Rfp --chef-repo-path #{path_to("chef_r~1")} /").should_succeed <<~EOM
|
107
109
|
/acls/
|
@@ -53,9 +53,9 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
53
53
|
context "and current_resource with state1=current, state2=current" do
|
54
54
|
before :each do
|
55
55
|
resource_class.load_current_value do
|
56
|
-
state1 "
|
57
|
-
state2 "
|
58
|
-
sensitive1 "
|
56
|
+
state1 "default_state1"
|
57
|
+
state2 "default_state2"
|
58
|
+
sensitive1 "default_dontprintme"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -86,7 +86,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
86
86
|
expect(converged_recipe.stdout).to eq <<~EOM
|
87
87
|
* #{resource_name}[blah] action create
|
88
88
|
- update default_identity1
|
89
|
-
- set state1 to "new_state1" (was "
|
89
|
+
- set state1 to "new_state1" (was "default_state1")
|
90
90
|
EOM
|
91
91
|
end
|
92
92
|
end
|
@@ -107,8 +107,8 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
107
107
|
expect(converged_recipe.stdout).to eq <<~EOM
|
108
108
|
* #{resource_name}[blah] action create
|
109
109
|
- update default_identity1
|
110
|
-
- set state1 to "new_state1" (was "
|
111
|
-
- set state2 to "new_state2" (was "
|
110
|
+
- set state1 to "new_state1" (was "default_state1")
|
111
|
+
- set state2 to "new_state2" (was "default_state2")
|
112
112
|
EOM
|
113
113
|
end
|
114
114
|
end
|
@@ -160,7 +160,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
160
160
|
let(:converge_recipe) do
|
161
161
|
<<-EOM
|
162
162
|
#{resource_name} 'blah' do
|
163
|
-
state1 '
|
163
|
+
state1 'default_state1'
|
164
164
|
state2 'new_state2'
|
165
165
|
end
|
166
166
|
EOM
|
@@ -172,7 +172,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
172
172
|
expect(converged_recipe.stdout).to eq <<~EOM
|
173
173
|
* #{resource_name}[blah] action create
|
174
174
|
- update default_identity1
|
175
|
-
- set state2 to "new_state2" (was "
|
175
|
+
- set state2 to "new_state2" (was "default_state2")
|
176
176
|
EOM
|
177
177
|
end
|
178
178
|
end
|
@@ -181,8 +181,8 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
181
181
|
let(:converge_recipe) do
|
182
182
|
<<-EOM
|
183
183
|
#{resource_name} 'blah' do
|
184
|
-
state1 '
|
185
|
-
state2 '
|
184
|
+
state1 'default_state1'
|
185
|
+
state2 'default_state2'
|
186
186
|
end
|
187
187
|
EOM
|
188
188
|
end
|
@@ -344,8 +344,8 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
344
344
|
context "and current_resource with state1=current, state2=current" do
|
345
345
|
before :each do
|
346
346
|
resource_class.load_current_value do
|
347
|
-
state1 "
|
348
|
-
state2 "
|
347
|
+
state1 "default_state1"
|
348
|
+
state2 "default_state2"
|
349
349
|
end
|
350
350
|
end
|
351
351
|
|
@@ -377,7 +377,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
377
377
|
expect(converged_recipe.stdout).to eq <<~EOM
|
378
378
|
* #{resource_name}[blah] action create
|
379
379
|
- update default_identity1
|
380
|
-
- set state1 to "new_state1" (was "
|
380
|
+
- set state1 to "new_state1" (was "default_state1")
|
381
381
|
EOM
|
382
382
|
end
|
383
383
|
end
|
@@ -398,9 +398,9 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
398
398
|
expect(converged_recipe.stdout).to eq <<~EOM
|
399
399
|
* #{resource_name}[blah] action create
|
400
400
|
- update default_identity1
|
401
|
-
- set state1 to "new_state1" (was "
|
401
|
+
- set state1 to "new_state1" (was "default_state1")
|
402
402
|
- update default_identity1
|
403
|
-
- set state2 to "new_state2" (was "
|
403
|
+
- set state2 to "new_state2" (was "default_state2")
|
404
404
|
EOM
|
405
405
|
end
|
406
406
|
end
|
@@ -409,7 +409,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
409
409
|
let(:converge_recipe) do
|
410
410
|
<<-EOM
|
411
411
|
#{resource_name} 'blah' do
|
412
|
-
state1 '
|
412
|
+
state1 'default_state1'
|
413
413
|
state2 'new_state2'
|
414
414
|
end
|
415
415
|
EOM
|
@@ -421,7 +421,7 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
421
421
|
expect(converged_recipe.stdout).to eq <<~EOM
|
422
422
|
* #{resource_name}[blah] action create
|
423
423
|
- update default_identity1
|
424
|
-
- set state2 to "new_state2" (was "
|
424
|
+
- set state2 to "new_state2" (was "default_state2")
|
425
425
|
EOM
|
426
426
|
end
|
427
427
|
end
|
@@ -430,8 +430,8 @@ describe "Resource::ActionClass#converge_if_changed" do
|
|
430
430
|
let(:converge_recipe) do
|
431
431
|
<<-EOM
|
432
432
|
#{resource_name} 'blah' do
|
433
|
-
state1 '
|
434
|
-
state2 '
|
433
|
+
state1 'default_state1'
|
434
|
+
state2 'default_state2'
|
435
435
|
end
|
436
436
|
EOM
|
437
437
|
end
|