chef 18.2.7 → 18.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/chef-universal-mingw-ucrt.gemspec +1 -1
- data/chef.gemspec +3 -3
- data/lib/chef/application/base.rb +2 -0
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +7 -9
- data/lib/chef/client.rb +2 -2
- data/lib/chef/cookbook/synchronizer.rb +19 -2
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/delayed_evaluator.rb +4 -0
- data/lib/chef/file_access_control/windows.rb +4 -1
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
- data/lib/chef/http/ssl_policies.rb +2 -2
- data/lib/chef/mixin/homebrew_user.rb +15 -5
- data/lib/chef/monkey_patches/net-http.rb +127 -0
- data/lib/chef/node/attribute_collections.rb +10 -1
- data/lib/chef/node/immutable_collections.rb +7 -3
- data/lib/chef/node/mixin/state_tracking.rb +1 -1
- data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
- data/lib/chef/node.rb +22 -0
- data/lib/chef/provider/launchd.rb +1 -1
- data/lib/chef/provider/mount/linux.rb +1 -1
- data/lib/chef/provider/mount/mount.rb +5 -5
- data/lib/chef/provider/package/apt.rb +11 -2
- data/lib/chef/provider/package/chocolatey.rb +239 -18
- data/lib/chef/provider/package/zypper.rb +6 -0
- data/lib/chef/provider/powershell_script.rb +96 -6
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +23 -8
- data/lib/chef/provider/service/windows.rb +1 -0
- data/lib/chef/provider/service.rb +14 -0
- data/lib/chef/provider/user.rb +5 -1
- data/lib/chef/provider/yum_repository.rb +1 -1
- data/lib/chef/recipe.rb +3 -11
- data/lib/chef/resource/_rest_resource.rb +1 -1
- data/lib/chef/resource/apt_package.rb +19 -0
- data/lib/chef/resource/apt_repository.rb +26 -6
- data/lib/chef/resource/chef_client_systemd_timer.rb +1 -1
- data/lib/chef/resource/chocolatey_installer.rb +207 -0
- data/lib/chef/resource/chocolatey_package.rb +8 -0
- data/lib/chef/resource/homebrew_cask.rb +6 -7
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +5 -5
- data/lib/chef/resource/launchd.rb +5 -1
- data/lib/chef/resource/locale.rb +5 -2
- data/lib/chef/resource/macos_pkg.rb +111 -0
- data/lib/chef/resource/powershell_script.rb +5 -1
- data/lib/chef/resource/service.rb +3 -0
- data/lib/chef/resource/sudo.rb +37 -2
- data/lib/chef/resource/support/ulimit.erb +40 -0
- data/lib/chef/resource/user_ulimit.rb +38 -0
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_security_policy.rb +2 -2
- data/lib/chef/resource.rb +11 -1
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/security.rb +7 -1
- data/spec/data/trusted_certs/example.crt +29 -20
- data/spec/data/trusted_certs/example_no_cn.crt +30 -34
- data/spec/functional/resource/chocolatey_package_spec.rb +32 -20
- data/spec/functional/resource/execute_spec.rb +1 -1
- data/spec/functional/resource/windows_certificate_spec.rb +25 -0
- data/spec/functional/resource/zypper_package_spec.rb +10 -0
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
- data/spec/unit/delayed_evaluator_spec.rb +35 -0
- data/spec/unit/mixin/homebrew_user_spec.rb +30 -7
- data/spec/unit/node/vivid_mash_spec.rb +42 -0
- data/spec/unit/node_spec.rb +6 -0
- data/spec/unit/provider/apt_repository_spec.rb +17 -7
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -2
- data/spec/unit/provider/mount/linux_spec.rb +6 -5
- data/spec/unit/provider/mount/mount_spec.rb +8 -8
- data/spec/unit/provider/package/apt_spec.rb +18 -13
- data/spec/unit/provider/package/chocolatey_spec.rb +53 -9
- data/spec/unit/provider/package/rpm_spec.rb +2 -2
- data/spec/unit/provider/package/zypper_spec.rb +10 -0
- data/spec/unit/provider/powershell_script_spec.rb +100 -4
- data/spec/unit/provider/remote_file/http_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
- data/spec/unit/provider/user/linux_spec.rb +10 -0
- data/spec/unit/resource/apt_repository_spec.rb +5 -0
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
- data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
- data/spec/unit/resource/macos_pkg_spec.rb +38 -0
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- data/spec/unit/resource_spec.rb +86 -0
- metadata +29 -16
- /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.nupkg → test-A.1.0.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.nupkg → test-A.1.5.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.nupkg → test-A.2.0.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.nupkg → test-B.1.0.0.nupkg} +0 -0
data/lib/chef/resource/sudo.rb
CHANGED
@@ -59,6 +59,41 @@ class Chef
|
|
59
59
|
nopasswd true
|
60
60
|
end
|
61
61
|
```
|
62
|
+
|
63
|
+
**Create command aliases and assign them to a group**
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
sudo 'webteam' do
|
67
|
+
command_aliases [
|
68
|
+
{
|
69
|
+
'name': 'WEBTEAM_SYSTEMD_JBOSS',
|
70
|
+
'command_list': [
|
71
|
+
'/usr/bin/systemctl start eap7-standalone.service',
|
72
|
+
'/usr/bin/systemctl start jbcs-httpd24-httpd.service', \
|
73
|
+
'/usr/bin/systemctl stop eap7-standalone.service', \
|
74
|
+
'/usr/bin/systemctl stop jbcs-httpd24-httpd.service', \
|
75
|
+
'/usr/bin/systemctl restart eap7-standalone.service', \
|
76
|
+
'/usr/bin/systemctl restart jbcs-httpd24-httpd.service', \
|
77
|
+
'/usr/bin/systemctl --full edit eap7-standalone.service', \
|
78
|
+
'/usr/bin/systemctl --full edit jbcs-httpd24-httpd.service', \
|
79
|
+
'/usr/bin/systemctl daemon-reload',
|
80
|
+
]
|
81
|
+
},
|
82
|
+
{
|
83
|
+
'name': 'GENERIC_SYSTEMD',
|
84
|
+
'command_list': [
|
85
|
+
'/usr/sbin/systemctl list-unit-files',
|
86
|
+
'/usr/sbin/systemctl list-timers', \
|
87
|
+
'/usr/sbin/systemctl is-active *', \
|
88
|
+
'/usr/sbin/systemctl is-enabled *',
|
89
|
+
]
|
90
|
+
}
|
91
|
+
]
|
92
|
+
nopasswd true
|
93
|
+
users '%webteam'
|
94
|
+
commands [ 'WEBTEAM_SYSTEMD_JBOSS', 'GENERIC_SYSTEMD' ]
|
95
|
+
end
|
96
|
+
```
|
62
97
|
DOC
|
63
98
|
|
64
99
|
# According to the sudo man pages sudo will ignore files in an include dir that have a `.` or `~`
|
@@ -79,7 +114,7 @@ class Chef
|
|
79
114
|
coerce: proc { |x| coerce_groups(x) }
|
80
115
|
|
81
116
|
property :commands, Array,
|
82
|
-
description: "An array of full paths to commands this sudoer can execute.",
|
117
|
+
description: "An array of full paths to commands and/or command aliases this sudoer can execute.",
|
83
118
|
default: ["ALL"]
|
84
119
|
|
85
120
|
property :host, String,
|
@@ -110,7 +145,7 @@ class Chef
|
|
110
145
|
default: []
|
111
146
|
|
112
147
|
property :command_aliases, Array,
|
113
|
-
description: "Command aliases that can be used as allowed commands later in the configuration.",
|
148
|
+
description: "Command aliases that can be used as allowed commands later in the configuration. The object represents an array of hashes in the following format: `[{'name':'ALIAS1','command_list': [ 'command1', 'command2' ] }, {'name':'Alias2','command_list: [ 'command3', 'command4 arg1 arg2' ]}]`",
|
114
149
|
default: []
|
115
150
|
|
116
151
|
property :setenv, [TrueClass, FalseClass],
|
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
# Limits settings for <%= @ulimit_user %>
|
4
4
|
|
5
|
+
<% unless @as_limit.nil? -%>
|
6
|
+
<%= @ulimit_user -%> - as <%= @as_limit %>
|
7
|
+
<% else -%><% unless @as_soft_limit.nil? -%><%= @ulimit_user -%> soft as <%= @as_soft_limit %><% end -%>
|
8
|
+
<% unless @as_hard_limit.nil? -%><%= @ulimit_user -%> hard as <%= @as_hard_limit %><% end -%>
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
<% unless @cpu_limit.nil? -%>
|
12
|
+
<%= @ulimit_user -%> - cpu <%= @cpu_limit %>
|
13
|
+
<% else -%><% unless @cpu_soft_limit.nil? -%><%= @ulimit_user -%> soft cpu <%= @cpu_soft_limit %><% end -%>
|
14
|
+
<% unless @cpu_hard_limit.nil? -%><%= @ulimit_user -%> hard cpu <%= @cpu_hard_limit %><% end -%>
|
15
|
+
<% end -%>
|
16
|
+
|
5
17
|
<% unless @filehandle_limit.nil? -%>
|
6
18
|
<%= @ulimit_user -%> - nofile <%= @filehandle_limit %>
|
7
19
|
<% else -%><% unless @filehandle_soft_limit.nil? -%><%= @ulimit_user -%> soft nofile <%= @filehandle_soft_limit %><% end -%>
|
@@ -14,22 +26,50 @@
|
|
14
26
|
<% unless @process_hard_limit.nil? -%><%= @ulimit_user -%> hard nproc <%= @process_hard_limit %><% end -%>
|
15
27
|
<% end -%>
|
16
28
|
|
29
|
+
<% unless @locks_limit.nil? -%>
|
30
|
+
<%= @ulimit_user -%> - locks <%= @locks_limit %>
|
31
|
+
<% end -%>
|
32
|
+
|
17
33
|
<% unless @memory_limit.nil? -%>
|
18
34
|
<%= @ulimit_user -%> - memlock <%= @memory_limit %>
|
19
35
|
<% end -%>
|
20
36
|
|
37
|
+
<% unless @maxlogins_limit.nil? -%>
|
38
|
+
<%= @ulimit_user -%> - maxlogins <%= @maxlogins_limit %>
|
39
|
+
<% else -%><% unless @maxlogins_soft_limit.nil? -%><%= @ulimit_user -%> soft maxlogins <%= @maxlogins_soft_limit %><% end -%>
|
40
|
+
<% unless @maxlogins_hard_limit.nil? -%><%= @ulimit_user -%> hard maxlogins <%= @maxlogins_hard_limit %><% end -%>
|
41
|
+
<% end -%>
|
42
|
+
|
43
|
+
<% unless @msgqueue_limit.nil? -%>
|
44
|
+
<%= @ulimit_user -%> - msgqueue <%= @msgqueue_limit %>
|
45
|
+
<% else -%><% unless @msgqueue_soft_limit.nil? -%><%= @ulimit_user -%> soft msgqueue <%= @msgqueue_soft_limit %><% end -%>
|
46
|
+
<% unless @msgqueue_hard_limit.nil? -%><%= @ulimit_user -%> hard msgqueue <%= @msgqueue_hard_limit %><% end -%>
|
47
|
+
<% end -%>
|
48
|
+
|
21
49
|
<% unless @core_limit.nil? -%>
|
22
50
|
<%= @ulimit_user -%> - core <%= @core_limit %>
|
23
51
|
<% else -%><% unless @core_soft_limit.nil? -%><%= @ulimit_user -%> soft core <%= @core_soft_limit %><% end -%>
|
24
52
|
<% unless @core_hard_limit.nil? -%><%= @ulimit_user -%> hard core <%= @core_hard_limit %><% end -%>
|
25
53
|
<% end -%>
|
26
54
|
|
55
|
+
<% unless @sigpending_limit.nil? -%>
|
56
|
+
<%= @ulimit_user -%> - sigpending <%= @sigpending_limit %>
|
57
|
+
<% else -%><% unless @sigpending_soft_limit.nil? -%><%= @ulimit_user -%> soft sigpending <%= @sigpending_soft_limit %><% end -%>
|
58
|
+
<% unless @sigpending_hard_limit.nil? -%><%= @ulimit_user -%> hard sigpending <%= @sigpending_hard_limit %><% end -%>
|
59
|
+
<% end -%>
|
60
|
+
|
27
61
|
<% unless @stack_limit.nil? -%>
|
28
62
|
<%= @ulimit_user -%> - stack <%= @stack_limit %>
|
29
63
|
<% else -%><% unless @stack_soft_limit.nil? -%><%= @ulimit_user -%> soft stack <%= @stack_soft_limit %><% end -%>
|
30
64
|
<% unless @stack_hard_limit.nil? -%><%= @ulimit_user -%> hard stack <%= @stack_hard_limit %><% end -%>
|
31
65
|
<% end -%>
|
32
66
|
|
67
|
+
<% unless @rss_limit.nil? -%>
|
68
|
+
<%= @ulimit_user -%> - rss <%= @rss_limit %>
|
69
|
+
<% else -%><% unless @rss_soft_limit.nil? -%><%= @ulimit_user -%> soft rss <%= @rss_soft_limit %><% end -%>
|
70
|
+
<% unless @rss_hard_limit.nil? -%><%= @ulimit_user -%> hard rss <%= @rss_hard_limit %><% end -%>
|
71
|
+
<% end -%>
|
72
|
+
|
33
73
|
<% unless @rtprio_limit.nil? -%>
|
34
74
|
<%= @ulimit_user -%> - rtprio <%= @rtprio_limit %>
|
35
75
|
<% else -%><% unless @rtprio_soft_limit.nil? -%><%= @ulimit_user -%> soft rtprio <%= @rtprio_soft_limit %><% end -%>
|
@@ -56,19 +56,38 @@ class Chef
|
|
56
56
|
DOC
|
57
57
|
|
58
58
|
property :username, String, name_property: true
|
59
|
+
property :as_limit, [String, Integer]
|
60
|
+
property :as_soft_limit, [String, Integer]
|
61
|
+
property :as_hard_limit, [String, Integer]
|
59
62
|
property :filehandle_limit, [String, Integer]
|
60
63
|
property :filehandle_soft_limit, [String, Integer]
|
61
64
|
property :filehandle_hard_limit, [String, Integer]
|
62
65
|
property :process_limit, [String, Integer]
|
63
66
|
property :process_soft_limit, [String, Integer]
|
64
67
|
property :process_hard_limit, [String, Integer]
|
68
|
+
property :locks_limit, [String, Integer]
|
65
69
|
property :memory_limit, [String, Integer]
|
70
|
+
property :maxlogins_limit, [String, Integer]
|
71
|
+
property :maxlogins_soft_limit, [String, Integer]
|
72
|
+
property :maxlogins_hard_limit, [String, Integer]
|
73
|
+
property :msgqueue_limit, [String, Integer]
|
74
|
+
property :msgqueue_soft_limit, [String, Integer]
|
75
|
+
property :msgqueue_hard_limit, [String, Integer]
|
66
76
|
property :core_limit, [String, Integer]
|
67
77
|
property :core_soft_limit, [String, Integer]
|
68
78
|
property :core_hard_limit, [String, Integer]
|
79
|
+
property :cpu_limit, [String, Integer]
|
80
|
+
property :cpu_soft_limit, [String, Integer]
|
81
|
+
property :cpu_hard_limit, [String, Integer]
|
82
|
+
property :sigpending_limit, [String, Integer]
|
83
|
+
property :sigpending_soft_limit, [String, Integer]
|
84
|
+
property :sigpending_hard_limit, [String, Integer]
|
69
85
|
property :stack_limit, [String, Integer]
|
70
86
|
property :stack_soft_limit, [String, Integer]
|
71
87
|
property :stack_hard_limit, [String, Integer]
|
88
|
+
property :rss_limit, [String, Integer]
|
89
|
+
property :rss_soft_limit, [String, Integer]
|
90
|
+
property :rss_hard_limit, [String, Integer]
|
72
91
|
property :rtprio_limit, [String, Integer]
|
73
92
|
property :rtprio_soft_limit, [String, Integer]
|
74
93
|
property :rtprio_hard_limit, [String, Integer]
|
@@ -85,19 +104,38 @@ class Chef
|
|
85
104
|
sensitive new_resource.sensitive
|
86
105
|
variables(
|
87
106
|
ulimit_user: new_resource.username,
|
107
|
+
as_limit: new_resource.as_limit,
|
108
|
+
as_soft_limit: new_resource.as_soft_limit,
|
109
|
+
as_hard_limit: new_resource.as_hard_limit,
|
88
110
|
filehandle_limit: new_resource.filehandle_limit,
|
89
111
|
filehandle_soft_limit: new_resource.filehandle_soft_limit,
|
90
112
|
filehandle_hard_limit: new_resource.filehandle_hard_limit,
|
91
113
|
process_limit: new_resource.process_limit,
|
92
114
|
process_soft_limit: new_resource.process_soft_limit,
|
93
115
|
process_hard_limit: new_resource.process_hard_limit,
|
116
|
+
locks_limit: new_resource.locks_limit,
|
94
117
|
memory_limit: new_resource.memory_limit,
|
118
|
+
maxlogins_limit: new_resource.maxlogins_limit,
|
119
|
+
maxlogins_soft_limit: new_resource.maxlogins_soft_limit,
|
120
|
+
maxlogins_hard_limit: new_resource.maxlogins_hard_limit,
|
121
|
+
msgqueue_limit: new_resource.msgqueue_limit,
|
122
|
+
msgqueue_soft_limit: new_resource.msgqueue_soft_limit,
|
123
|
+
msgqueue_hard_limit: new_resource.msgqueue_hard_limit,
|
95
124
|
core_limit: new_resource.core_limit,
|
96
125
|
core_soft_limit: new_resource.core_soft_limit,
|
97
126
|
core_hard_limit: new_resource.core_hard_limit,
|
127
|
+
cpu_limit: new_resource.cpu_limit,
|
128
|
+
cpu_soft_limit: new_resource.cpu_soft_limit,
|
129
|
+
cpu_hard_limit: new_resource.cpu_hard_limit,
|
130
|
+
sigpending_limit: new_resource.sigpending_limit,
|
131
|
+
sigpending_soft_limit: new_resource.sigpending_soft_limit,
|
132
|
+
sigpending_hard_limit: new_resource.sigpending_hard_limit,
|
98
133
|
stack_limit: new_resource.stack_limit,
|
99
134
|
stack_soft_limit: new_resource.stack_soft_limit,
|
100
135
|
stack_hard_limit: new_resource.stack_hard_limit,
|
136
|
+
rss_limit: new_resource.rss_limit,
|
137
|
+
rss_soft_limit: new_resource.rss_soft_limit,
|
138
|
+
rss_hard_limit: new_resource.rss_hard_limit,
|
101
139
|
rtprio_limit: new_resource.rtprio_limit,
|
102
140
|
rtprio_soft_limit: new_resource.rtprio_soft_limit,
|
103
141
|
rtprio_hard_limit: new_resource.rtprio_hard_limit,
|
@@ -440,7 +440,7 @@ class Chef
|
|
440
440
|
def export_cert(cert_obj, output_path:, store_name:, store_location:, pfx_password:)
|
441
441
|
# Delete the cert if it exists on disk already.
|
442
442
|
# We want to ensure we're not randomly loading an old stinky cert.
|
443
|
-
if ::File.
|
443
|
+
if ::File.exist?(output_path)
|
444
444
|
::File.delete(output_path)
|
445
445
|
end
|
446
446
|
|
@@ -118,13 +118,13 @@ class Chef
|
|
118
118
|
file.write("[Unicode]\r\nUnicode=yes\r\n[System Access]\r\n#{policy_line}\r\n[Version]\r\nsignature=\"$CHICAGO$\"\r\nRevision=1\r\n")
|
119
119
|
file.close
|
120
120
|
file_path = file.path.tr("/", "\\")
|
121
|
-
cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg #{file_path} /areas SECURITYPOLICY"
|
121
|
+
cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg \"#{file_path}\" /areas SECURITYPOLICY"
|
122
122
|
else
|
123
123
|
policy_line = "#{security_option} = #{security_value}"
|
124
124
|
file.write("[Unicode]\r\nUnicode=yes\r\n[System Access]\r\n#{policy_line}\r\n[Version]\r\nsignature=\"$CHICAGO$\"\r\nRevision=1\r\n")
|
125
125
|
file.close
|
126
126
|
file_path = file.path.tr("/", "\\")
|
127
|
-
cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg #{file_path} /areas SECURITYPOLICY"
|
127
|
+
cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg \"#{file_path}\" /areas SECURITYPOLICY"
|
128
128
|
end
|
129
129
|
shell_out!(cmd)
|
130
130
|
file.unlink
|
data/lib/chef/resource.rb
CHANGED
@@ -1508,7 +1508,17 @@ class Chef
|
|
1508
1508
|
dirname = ::File.dirname(partial)
|
1509
1509
|
basename = ::File.basename(partial, ".rb")
|
1510
1510
|
basename = basename[1..] if basename.start_with?("_")
|
1511
|
-
|
1511
|
+
|
1512
|
+
# Support recursive `use`
|
1513
|
+
callers = caller_locations
|
1514
|
+
used_from = if callers.first.label == "use"
|
1515
|
+
callers.detect { |caller| caller.label == "class_from_file" }.path
|
1516
|
+
else
|
1517
|
+
callers.first.path
|
1518
|
+
end
|
1519
|
+
|
1520
|
+
fullpath = ::File.expand_path("#{dirname}/_#{basename}.rb", ::File.dirname(used_from))
|
1521
|
+
class_eval IO.read(fullpath)
|
1512
1522
|
end
|
1513
1523
|
end
|
1514
1524
|
|
data/lib/chef/resources.rb
CHANGED
@@ -39,6 +39,7 @@ require_relative "resource/chef_sleep"
|
|
39
39
|
require_relative "resource/chef_vault_secret"
|
40
40
|
require_relative "resource/chocolatey_config"
|
41
41
|
require_relative "resource/chocolatey_feature"
|
42
|
+
require_relative "resource/chocolatey_installer"
|
42
43
|
require_relative "resource/chocolatey_package"
|
43
44
|
require_relative "resource/chocolatey_source"
|
44
45
|
require_relative "resource/cron/cron"
|
@@ -83,6 +84,7 @@ require_relative "resource/link"
|
|
83
84
|
require_relative "resource/locale"
|
84
85
|
require_relative "resource/log"
|
85
86
|
require_relative "resource/macports_package"
|
87
|
+
require_relative "resource/macos_pkg"
|
86
88
|
require_relative "resource/macos_userdefaults"
|
87
89
|
require_relative "resource/mdadm"
|
88
90
|
require_relative "resource/mount"
|
data/lib/chef/version.rb
CHANGED
data/lib/chef/win32/security.rb
CHANGED
@@ -721,7 +721,13 @@ class Chef
|
|
721
721
|
unless LogonUserW(username, domain, password, logon_type, logon_provider, token)
|
722
722
|
Chef::ReservedNames::Win32::Error.raise!
|
723
723
|
end
|
724
|
-
|
724
|
+
|
725
|
+
# originally this was .read_pointer, but that is interpreted as a non-primitive
|
726
|
+
# class (FFI::Pointer) and causes an ArgumentError (Invalid Memory Object) when
|
727
|
+
# compared to GetCurrentProcess(), which returns a HANDLE (void *). Since a
|
728
|
+
# HANDLE is not a pointer to allocated memory that Ruby C extensions can understand,
|
729
|
+
# the Invalid Memory Object error is raised.
|
730
|
+
Token.new(Handle.new(token.read_ulong))
|
725
731
|
end
|
726
732
|
|
727
733
|
def self.test_and_raise_lsa_nt_status(result)
|
@@ -1,22 +1,31 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
/
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
2
|
+
MIIFPTCCAyWgAwIBAgIUPv2sKSZA+KW0a4LxgUhiZG48AkswDQYJKoZIhvcNAQEL
|
3
|
+
BQAwFzEVMBMGA1UEAwwMZXhhbXBsZS4uY29tMB4XDTIzMTAxNjE2MzM1M1oXDTMz
|
4
|
+
MTAxMzE2MzM1M1owFzEVMBMGA1UEAwwMZXhhbXBsZS4uY29tMIICIjANBgkqhkiG
|
5
|
+
9w0BAQEFAAOCAg8AMIICCgKCAgEA1NKZJQY7B8xGnaERMX4laepq3u00q1nSDS6j
|
6
|
+
03qd1z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BckD0sSG8j50x2of9NS3vFFgWM1Cas55XWzlkDGbIJMlrKOj01bUYNq
|
29
|
+
ltmMfavmpMPA86p8QHRmWlQhtgu+OK/8RxmGtQdtBi8Gdk3mNMkokSQCVcDWvNhX
|
30
|
+
pVFCGya51orBgbWqxbAsIeiv7Pl85edXm8KolJ389xkXqFvX31hme5KnyBhCcRrv
|
31
|
+
EZbXRhY3O58t7SlKWVCnx/JmEkJcRJtZaEReF1LbBayExYNnj/sD
|
36
32
|
-----END CERTIFICATE-----
|
@@ -22,8 +22,16 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
|
|
22
22
|
include Chef::Mixin::ShellOut
|
23
23
|
|
24
24
|
let(:package_name) { "test-A" }
|
25
|
-
let(:package_list) { proc { shell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
|
26
25
|
let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
|
26
|
+
let(:package_list) do
|
27
|
+
if provider.query_command == "list"
|
28
|
+
# using result of query_command because that indicates which "search" command to use
|
29
|
+
# which coincides with the package list output
|
30
|
+
proc { shell_out!("choco search -lo #{Array(package_name).join(" ")}").stdout.chomp }
|
31
|
+
else
|
32
|
+
proc { shell_out!("choco list #{Array(package_name).join(" ")}").stdout.chomp }
|
33
|
+
end
|
34
|
+
end
|
27
35
|
|
28
36
|
let(:run_context) do
|
29
37
|
Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
|
@@ -54,12 +62,16 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
|
|
54
62
|
ENV["Path"] = ENV.delete("Path")
|
55
63
|
end
|
56
64
|
|
65
|
+
after(:each) do
|
66
|
+
provider.instance_variable_set(:@get_choco_version, nil)
|
67
|
+
end
|
68
|
+
|
57
69
|
context "installing a package" do
|
58
70
|
after { remove_package }
|
59
71
|
|
60
72
|
it "installs the latest version" do
|
61
73
|
subject.run_action(:install)
|
62
|
-
expect(package_list.call).to
|
74
|
+
expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
|
63
75
|
end
|
64
76
|
|
65
77
|
it "does not install if already installed" do
|
@@ -69,19 +81,19 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
|
|
69
81
|
end
|
70
82
|
|
71
83
|
it "installs version given" do
|
72
|
-
subject.version "1.0"
|
84
|
+
subject.version "1.0.0"
|
73
85
|
subject.run_action(:install)
|
74
|
-
expect(package_list.call).to
|
86
|
+
expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
|
75
87
|
end
|
76
88
|
|
77
89
|
it "installs new version if one is already installed" do
|
78
|
-
subject.version "1.0"
|
90
|
+
subject.version "1.0.0"
|
79
91
|
subject.run_action(:install)
|
80
|
-
expect(package_list.call).to
|
92
|
+
expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
|
81
93
|
|
82
|
-
subject.version "2.0"
|
94
|
+
subject.version "2.0.0"
|
83
95
|
subject.run_action(:install)
|
84
|
-
expect(package_list.call).to
|
96
|
+
expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
|
85
97
|
end
|
86
98
|
|
87
99
|
context "installing multiple packages" do
|
@@ -89,7 +101,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
|
|
89
101
|
|
90
102
|
it "installs both packages" do
|
91
103
|
subject.run_action(:install)
|
92
|
-
expect(package_list.call).to
|
104
|
+
expect(package_list.call).to match(/^test-A|2.0.0\r\ntest-B|1.0.0$/)
|
93
105
|
end
|
94
106
|
end
|
95
107
|
|
@@ -101,13 +113,13 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
|
|
101
113
|
it "installs with an option as a string" do
|
102
114
|
subject.options "--force --confirm"
|
103
115
|
subject.run_action(:install)
|
104
|
-
expect(package_list.call).to
|
116
|
+
expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
|
105
117
|
end
|
106
118
|
|
107
119
|
it "installs with multiple options as a string" do
|
108
120
|
subject.options "--force --confirm"
|
109
121
|
subject.run_action(:install)
|
110
|
-
expect(package_list.call).to
|
122
|
+
expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
|
111
123
|
end
|
112
124
|
|
113
125
|
context "when multiple options passed as string" do
|
@@ -137,7 +149,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
|
|
137
149
|
it "installs with multiple options as an array" do
|
138
150
|
subject.options [ "--force", "--confirm" ]
|
139
151
|
subject.run_action(:install)
|
140
|
-
expect(package_list.call).to
|
152
|
+
expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
|
141
153
|
end
|
142
154
|
end
|
143
155
|
|
@@ -145,24 +157,24 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
|
|
145
157
|
after { remove_package }
|
146
158
|
|
147
159
|
it "upgrades to a specific version" do
|
148
|
-
subject.version "1.0"
|
160
|
+
subject.version "1.0.0"
|
149
161
|
subject.run_action(:install)
|
150
|
-
expect(package_list.call).to
|
162
|
+
expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
|
151
163
|
|
152
|
-
subject.version "1.5"
|
164
|
+
subject.version "1.5.0"
|
153
165
|
subject.run_action(:upgrade)
|
154
|
-
expect(package_list.call).to
|
166
|
+
expect(package_list.call).to match(/^#{package_name}|1.5.0$/)
|
155
167
|
end
|
156
168
|
|
157
169
|
it "upgrades to the latest version if no version given" do
|
158
|
-
subject.version "1.0"
|
170
|
+
subject.version "1.0.0"
|
159
171
|
subject.run_action(:install)
|
160
|
-
expect(package_list.call).to
|
172
|
+
expect(package_list.call).to match(/^#{package_name}|1.0.0$/)
|
161
173
|
|
162
174
|
subject2 = Chef::Resource::ChocolateyPackage.new("test-A", run_context)
|
163
175
|
subject2.source package_source
|
164
176
|
subject2.run_action(:upgrade)
|
165
|
-
expect(package_list.call).to
|
177
|
+
expect(package_list.call).to match(/^#{package_name}|2.0.0$/)
|
166
178
|
end
|
167
179
|
end
|
168
180
|
|
@@ -170,7 +182,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
|
|
170
182
|
it "removes an installed package" do
|
171
183
|
subject.run_action(:install)
|
172
184
|
remove_package
|
173
|
-
expect(package_list.call).to
|
185
|
+
expect(package_list.call).to match(/0 packages installed/)
|
174
186
|
end
|
175
187
|
end
|
176
188
|
|
@@ -62,7 +62,7 @@ describe Chef::Resource::Execute do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "when parent resource sets :cwd" do
|
65
|
-
let(:guard) { %{ruby -e 'exit 1 unless File.
|
65
|
+
let(:guard) { %{ruby -e 'exit 1 unless File.exist?("./nested.json")'} }
|
66
66
|
|
67
67
|
it "guard inherits :cwd from resource and runs" do
|
68
68
|
resource.cwd CHEF_SPEC_DATA
|
@@ -56,6 +56,30 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
|
|
56
56
|
let(:store) { "Chef-Functional-Test" }
|
57
57
|
let(:store_name) { "MY" }
|
58
58
|
let(:store_location) { "LocalMachine" }
|
59
|
+
let(:test_cert_body) do
|
60
|
+
<<~CERT
|
61
|
+
-----BEGIN CERTIFICATE-----
|
62
|
+
MIIDQTCCAimgAwIBAgIQX3zqNCJbsKlEvzCz3Z9aNDANBgkqhkiG9w0BAQsFADAh
|
63
|
+
MR8wHQYDVQQDDBZ3d3cuZHVtbXljaGVmdGVzdHMuY29tMCAXDTIwMDMwNTEwMjcw
|
64
|
+
NVoYDzIxMjAwMzA1MTAzNzA2WjAhMR8wHQYDVQQDDBZ3d3cuZHVtbXljaGVmdGVz
|
65
|
+
dHMuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtuYKDb6woWIH
|
66
|
+
HPPOrcVpgJFVxbkjgk+tsYwbIiqR9jtRaKE6nM/awOgn9/dFF4k8KB8Em0sUx7Vq
|
67
|
+
J3YhK2N2cAacgP2Frqqf5znpNBBOg968RoZzGx0EiXFvLsqC4y8ggApWTbMXPRk4
|
68
|
+
1a7GlpUpSqI3y5cLeEbzwGQKu8I1I+v7P2fTlnJPHarM7sBbL8bieukkFHYu78iV
|
69
|
+
u1wpKOCCfs5DTmJu8WN+z1Mar9vyrWMBlt2wBBgNHPz5mcXUzJHTzaI/D9RGgBgF
|
70
|
+
V0IkNqISx/IzR62jjj2g6MgTH4G/0mM6O5sxduM4yGmWZNZpVzh0yMLgH619MZlj
|
71
|
+
SMQIN3U/SQIDAQABo3MwcTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYB
|
72
|
+
BQUHAwIGCCsGAQUFBwMBMCEGA1UdEQQaMBiCFnd3dy5kdW1teWNoZWZ0ZXN0cy5j
|
73
|
+
b20wHQYDVR0OBBYEFHwS3gs03m6RcpR+66u4OqGiZdYnMA0GCSqGSIb3DQEBCwUA
|
74
|
+
A4IBAQCFHqMjHUfBZahIsKHQIcFCbC1NFh1ZHlJKZzrRBRwRzX19OttHGMyLpDd6
|
75
|
+
tM9Ac6LLR8S4QIWg+HF3IrkN+vfTRDZAccj+tIwBRstmdsEz/rAJ79Vb/00mXZQx
|
76
|
+
0FPiBDR3hE7On2oo24DU8kJP3v6TrunwtIomVGqrrkwZzvxqyW+WJMB2shGNFw5J
|
77
|
+
mKYBiiXsHl4Bi7V4zhXssrLp877sqpNLeXloXBmAlT39SwQTP9ImZaV5R6udqlvo
|
78
|
+
Gfgm5PH/WeK6MV3n5ik0v1rS0LwR2o82WlIB6a4iSEbzY3qSLsWOwt8o5QjAVzCR
|
79
|
+
tNdbdS3U8nrG73iA2clmF57ARQWC
|
80
|
+
-----END CERTIFICATE-----
|
81
|
+
CERT
|
82
|
+
end
|
59
83
|
let(:download_cert_url) { "https://testingchef.blob.core.windows.net/files/test.cer" }
|
60
84
|
let(:cert_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.cer") }
|
61
85
|
let(:pfx_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.pfx") }
|
@@ -128,6 +152,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
|
|
128
152
|
end
|
129
153
|
|
130
154
|
it "can add a certificate from a valid url" do
|
155
|
+
stub_request(:get, download_cert_url).to_return(body: test_cert_body)
|
131
156
|
resource.source = download_cert_url
|
132
157
|
resource.run_action(:create)
|
133
158
|
|
@@ -189,6 +189,15 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
|
|
189
189
|
expect(zypper_package.updated_by_last_action?).to be true
|
190
190
|
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
191
191
|
end
|
192
|
+
|
193
|
+
context "Package doesn't exist" do
|
194
|
+
let(:package_name) { "nonexistent_repo" }
|
195
|
+
it "does nothing if the package is not installed" do
|
196
|
+
zypper_package.run_action(:remove)
|
197
|
+
expect(zypper_package.updated_by_last_action?).to be false
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
192
201
|
end
|
193
202
|
|
194
203
|
context "with no available version" do
|
@@ -259,6 +268,7 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
|
|
259
268
|
expect(shell_out("zypper locks | grep chef_rpm_provides").stdout.chomp).not_to match("chef_rpm_provides")
|
260
269
|
end
|
261
270
|
end
|
271
|
+
|
262
272
|
def remove_package
|
263
273
|
pkg_to_remove = Chef::Resource::ZypperPackage.new(package_name, run_context)
|
264
274
|
pkg_to_remove.run_action(:remove)
|
data/spec/unit/client_spec.rb
CHANGED
@@ -119,8 +119,8 @@ shared_context "a client run" do
|
|
119
119
|
# Make sure Client#register thinks the client key doesn't
|
120
120
|
# exist, so it tries to register and create one.
|
121
121
|
allow(Chef::HTTP::Authenticator).to receive(:detect_certificate_key).with(fqdn).and_return(false)
|
122
|
-
allow(File).to receive(:
|
123
|
-
expect(File).to receive(:
|
122
|
+
allow(File).to receive(:exist?).and_call_original
|
123
|
+
expect(File).to receive(:exist?)
|
124
124
|
.with(Chef::Config[:client_key])
|
125
125
|
.exactly(:once)
|
126
126
|
.and_return(api_client_exists?)
|