chef 17.8.25 → 17.9.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/provider/cron.rb +2 -2
- data/lib/chef/provider/directory.rb +2 -2
- data/lib/chef/provider/ifconfig.rb +4 -4
- data/lib/chef/provider/package/yum/python_helper.rb +81 -25
- data/lib/chef/provider/package/yum.rb +39 -12
- data/lib/chef/provider/package.rb +4 -4
- data/lib/chef/provider.rb +4 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/resource/apt_package.rb +2 -2
- data/lib/chef/resource/chef_client_config.rb +2 -3
- data/lib/chef/resource/chocolatey_package.rb +3 -3
- data/lib/chef/resource/cron/cron.rb +75 -1
- data/lib/chef/resource/cron/cron_d.rb +2 -1
- data/lib/chef/resource/homebrew_tap.rb +0 -4
- data/lib/chef/resource/powershell_package_source.rb +8 -8
- data/lib/chef/resource/rhsm_register.rb +3 -3
- data/lib/chef/resource/windows_feature_powershell.rb +1 -2
- data/lib/chef/resource/windows_task.rb +25 -10
- data/lib/chef/secret_fetcher/azure_key_vault.rb +2 -0
- data/lib/chef/secret_fetcher/hashi_vault.rb +37 -3
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/dnf_package_spec.rb +107 -107
- data/spec/functional/resource/yum_package_spec.rb +789 -129
- data/spec/unit/secret_fetcher/hashi_vault_spec.rb +46 -0
- metadata +6 -8
- data/lib/chef/provider/group/suse.rb +0 -82
- data/spec/unit/provider/group/suse_spec.rb +0 -90
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1886ca1ea538fbe96bf89e02df660eaa7eead201d917e15525e63cb7b3c3f90c
|
4
|
+
data.tar.gz: 2f2807b137aba35aba5ab1fa719ed26d0dd5aaab8ba4989c56c33b62761c3bfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e52940ab6008d9263848045de3be99288298a6b542a94e9fa6832f2e2cdb73369b0055ec1df63237338faf8f0015d65f138985201452e7b64e15ddd8a76d1619
|
7
|
+
data.tar.gz: ea68a2d6a8096d590877bef7b764b8b6283980354401b2f713177b3977ba7338bb2bd012433ae0a203cb42deacf10865a288a4b3fcedcb9d9cd0c423b749c9da
|
data/lib/chef/provider/cron.rb
CHANGED
@@ -92,7 +92,7 @@ class Chef
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
action :create do
|
95
|
+
action :create, description: "Create an entry in a cron table file (crontab). If an entry already exists (but does not match), update that entry to match." do
|
96
96
|
crontab = ""
|
97
97
|
newcron = ""
|
98
98
|
cron_found = false
|
@@ -149,7 +149,7 @@ class Chef
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
action :delete do
|
152
|
+
action :delete, description: "Delete an entry from a cron table file (crontab)." do
|
153
153
|
if @cron_exists
|
154
154
|
crontab = ""
|
155
155
|
cron_found = false
|
@@ -121,7 +121,7 @@ class Chef
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
action :create do
|
124
|
+
action :create, description: "Create a directory. If a directory already exists (but does not match), update that directory to match." do
|
125
125
|
unless ::File.exist?(new_resource.path)
|
126
126
|
converge_by("create new directory #{new_resource.path}") do
|
127
127
|
if new_resource.recursive == true
|
@@ -137,7 +137,7 @@ class Chef
|
|
137
137
|
load_resource_attributes_from_file(new_resource) unless Chef::Config[:why_run]
|
138
138
|
end
|
139
139
|
|
140
|
-
action :delete do
|
140
|
+
action :delete, description: "Delete a directory." do
|
141
141
|
if ::File.exist?(new_resource.path)
|
142
142
|
converge_by("delete existing directory #{new_resource.path}") do
|
143
143
|
if new_resource.recursive == true
|
@@ -168,7 +168,7 @@ class Chef
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
-
action :add do
|
171
|
+
action :add, description: "Run ifconfig to configure a network interface and (on some platforms) write a configuration file for that network interface." do
|
172
172
|
# check to see if load_current_resource found interface in ifconfig
|
173
173
|
unless current_resource.inet_addr
|
174
174
|
unless new_resource.device == loopback_device
|
@@ -183,7 +183,7 @@ class Chef
|
|
183
183
|
generate_config
|
184
184
|
end
|
185
185
|
|
186
|
-
action :enable do
|
186
|
+
action :enable, description: "Run ifconfig to enable a network interface." do
|
187
187
|
# check to see if load_current_resource found ifconfig
|
188
188
|
# enables, but does not manage config files
|
189
189
|
return if current_resource.inet_addr
|
@@ -196,7 +196,7 @@ class Chef
|
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
|
-
action :delete do
|
199
|
+
action :delete, description: "Run ifconfig to disable a network interface and (on some platforms) delete that network interface’s configuration file." do
|
200
200
|
# check to see if load_current_resource found the interface
|
201
201
|
if current_resource.device
|
202
202
|
command = delete_command
|
@@ -210,7 +210,7 @@ class Chef
|
|
210
210
|
delete_config
|
211
211
|
end
|
212
212
|
|
213
|
-
action :disable do
|
213
|
+
action :disable, description: "Run ifconfig to disable a network interface." do
|
214
214
|
# check to see if load_current_resource found the interface
|
215
215
|
# disables, but leaves config files in place.
|
216
216
|
if current_resource.device
|
@@ -115,10 +115,90 @@ class Chef
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
def is_arch?(arch)
|
119
|
+
# cspell:disable-next
|
120
|
+
arches = %w{aarch64 alpha alphaev4 alphaev45 alphaev5 alphaev56 alphaev6 alphaev67 alphaev68 alphaev7 alphapca56 armv5tejl armv5tel armv5tl armv6l armv7l armv8l armv6hl armv7hl armv7hnl armv8hl i386 athlon geode i386 i486 i586 i686 ia64 mips mipsel mips64 mips64el noarch ppc ppc64 ppc64iseries ppc64p7 ppc64pseries ppc64le riscv32 riscv64 riscv128 s390 s390x sh3 sh4 sh4a sparc sparc64 sparc64v sparcv8 sparcv9 sparcv9v x86_64 amd64 ia32e}
|
121
|
+
arches.include?(arch)
|
122
|
+
end
|
123
|
+
|
124
|
+
# We have a provides line with an epoch in it and yum cannot parse that, so we
|
125
|
+
# need to deconstruct the args. This doesn't support splats which is why we
|
126
|
+
# only do it for this particularly narrow use case.
|
127
|
+
#
|
128
|
+
# name-epoch:version
|
129
|
+
# name-epoch:version.arch
|
130
|
+
# name-epoch:version-release
|
131
|
+
# name-epoch:version-release.arch
|
132
|
+
#
|
133
|
+
# @api private
|
134
|
+
def deconstruct_args(provides)
|
135
|
+
raise "provides must have an epoch in the version to deconstruct" unless provides =~ /^(\S+)-(\d+):(\S+)/
|
136
|
+
|
137
|
+
name = $1
|
138
|
+
epoch = $2
|
139
|
+
other = $3
|
140
|
+
ret = { "provides" => name, "epoch" => epoch }
|
141
|
+
maybe_arch = other.rpartition(".").last
|
142
|
+
arch = if is_arch?(maybe_arch)
|
143
|
+
other.delete_suffix!(".#{maybe_arch}")
|
144
|
+
maybe_arch
|
145
|
+
end
|
146
|
+
ret.merge!({ "arch" => arch }) if arch
|
147
|
+
(version, _, release) = other.rpartition("-")
|
148
|
+
if version.empty?
|
149
|
+
ret.merge!({ "version" => release }) # yeah, rpartition is just weird
|
150
|
+
else
|
151
|
+
ret.merge!({ "version" => version, "release" => release })
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# In the default case for the yum provider we now do terrible things with ruby
|
156
|
+
# to concatenate all the properties together to form a single string to feed to
|
157
|
+
# the python which favors using returnPackages/searchProvides over the
|
158
|
+
# searchNevra API. That means that these two different ways of constructing the
|
159
|
+
# resource are now perfectly identical:
|
160
|
+
#
|
161
|
+
# yum_package "zabbix-agent-4.0.15-1.fc31.x86_64"
|
162
|
+
#
|
163
|
+
# yum_package "zabbix-agent" do
|
164
|
+
# version "4.0.15-1.fc31"
|
165
|
+
# arch "x86_64"
|
166
|
+
# end
|
167
|
+
#
|
168
|
+
# This function handles turning the second form into the first form.
|
169
|
+
#
|
170
|
+
# In the case where the epoch is given in the version and we do not have any glob
|
171
|
+
# patterns that is handled by going the other way and calling deconstruct_args due
|
172
|
+
# to the yum libraries not supporting that calling pattern other than by searchNevra.
|
173
|
+
#
|
174
|
+
# NOTE: This is an ugly hack and should NOT be considered an endorsement of this approach
|
175
|
+
# towards any kind of features or bugfixes in the DNF provider. I'm doing this
|
176
|
+
# because YUM is sunsetting at this point and its very difficult to fight with the
|
177
|
+
# libraries on the python side of things.
|
178
|
+
#
|
179
|
+
# @api private
|
180
|
+
def combine_args(provides, version, arch)
|
181
|
+
provides = provides.dup
|
182
|
+
maybe_arch = provides.rpartition(".").last
|
183
|
+
if is_arch?(maybe_arch)
|
184
|
+
arch = maybe_arch
|
185
|
+
provides.delete_suffix!(".#{arch}")
|
186
|
+
end
|
187
|
+
provides = "#{provides}-#{version}" if version
|
188
|
+
provides = "#{provides}.#{arch}" if arch
|
189
|
+
# yum (on rhel7) can't handle an epoch in provides, but
|
190
|
+
# deconstructing the args can't handle dealing with globs
|
191
|
+
if provides =~ /-\d+:/ && provides !~ /[\*\?]/
|
192
|
+
deconstruct_args(provides)
|
193
|
+
else
|
194
|
+
{ "provides" => provides }
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
118
198
|
# @return Array<Version>
|
119
199
|
# NB: "options" here is the yum_package options hash and is deliberately not **opts
|
120
200
|
def package_query(action, provides, version: nil, arch: nil, options: {})
|
121
|
-
parameters =
|
201
|
+
parameters = combine_args(provides, version, arch)
|
122
202
|
repo_opts = options_params(options || {})
|
123
203
|
parameters.merge!(repo_opts)
|
124
204
|
# XXX: for now we close the rpmdb before and after every query with an enablerepo/disablerepo to clean the helpers internal state
|
@@ -137,25 +217,6 @@ class Chef
|
|
137
217
|
|
138
218
|
private
|
139
219
|
|
140
|
-
# i couldn't figure out how to decompose an evr on the python side, it seems reasonably
|
141
|
-
# painless to do it in ruby (generally massaging nevras in the ruby side is HIGHLY
|
142
|
-
# discouraged -- this is an "every rule has an exception" exception -- any additional
|
143
|
-
# functionality should probably trigger moving this regexp logic into python)
|
144
|
-
def add_version(hash, version)
|
145
|
-
epoch = nil
|
146
|
-
if version =~ /(\S+):(\S+)/
|
147
|
-
epoch = $1
|
148
|
-
version = $2
|
149
|
-
end
|
150
|
-
if version =~ /(\S+)-(\S+)/
|
151
|
-
version = $1
|
152
|
-
release = $2
|
153
|
-
end
|
154
|
-
hash["epoch"] = epoch unless epoch.nil?
|
155
|
-
hash["release"] = release unless release.nil?
|
156
|
-
hash["version"] = version
|
157
|
-
end
|
158
|
-
|
159
220
|
def query(action, parameters)
|
160
221
|
with_helper do
|
161
222
|
json = build_query(action, parameters)
|
@@ -174,11 +235,6 @@ class Chef
|
|
174
235
|
hash[param_name] = param_value unless param_value.nil?
|
175
236
|
end
|
176
237
|
|
177
|
-
# Special handling for certain action / param combos
|
178
|
-
if %i{whatinstalled whatavailable}.include?(action)
|
179
|
-
add_version(hash, parameters["version"]) unless parameters["version"].nil?
|
180
|
-
end
|
181
|
-
|
182
238
|
FFI_Yajl::Encoder.encode(hash)
|
183
239
|
end
|
184
240
|
|
@@ -36,6 +36,7 @@ class Chef
|
|
36
36
|
allow_nils
|
37
37
|
use_multipackage_api
|
38
38
|
use_package_name_for_source
|
39
|
+
use_magic_version
|
39
40
|
|
40
41
|
provides :package, platform_family: "fedora_derived"
|
41
42
|
|
@@ -64,6 +65,16 @@ class Chef
|
|
64
65
|
current_resource
|
65
66
|
end
|
66
67
|
|
68
|
+
def load_after_resource
|
69
|
+
# force the installed version array to repopulate
|
70
|
+
@current_version = []
|
71
|
+
@after_resource = Chef::Resource::YumPackage.new(new_resource.name)
|
72
|
+
after_resource.package_name(new_resource.package_name)
|
73
|
+
after_resource.version(get_current_versions)
|
74
|
+
|
75
|
+
after_resource
|
76
|
+
end
|
77
|
+
|
67
78
|
def define_resource_requirements
|
68
79
|
requirements.assert(:install, :upgrade, :remove, :purge) do |a|
|
69
80
|
a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
|
@@ -80,9 +91,15 @@ class Chef
|
|
80
91
|
end
|
81
92
|
end
|
82
93
|
|
94
|
+
def magic_version_array
|
95
|
+
package_name_array.each_with_index.map do |pkg, i|
|
96
|
+
magical_version(i).version_with_arch
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
83
100
|
def get_current_versions
|
84
101
|
package_name_array.each_with_index.map do |pkg, i|
|
85
|
-
|
102
|
+
current_version(i).version_with_arch
|
86
103
|
end
|
87
104
|
end
|
88
105
|
|
@@ -127,7 +144,7 @@ class Chef
|
|
127
144
|
alias upgrade_package install_package
|
128
145
|
|
129
146
|
def remove_package(names, versions)
|
130
|
-
resolved_names = names.each_with_index.map { |name, i|
|
147
|
+
resolved_names = names.each_with_index.map { |name, i| magical_version(i).to_s unless name.nil? }
|
131
148
|
yum(options, "-y", "remove", resolved_names)
|
132
149
|
flushcache
|
133
150
|
end
|
@@ -157,10 +174,10 @@ class Chef
|
|
157
174
|
def resolved_package_lock_names(names)
|
158
175
|
names.each_with_index.map do |name, i|
|
159
176
|
unless name.nil?
|
160
|
-
if
|
177
|
+
if magical_version(i).version.nil?
|
161
178
|
available_version(i).name
|
162
179
|
else
|
163
|
-
|
180
|
+
magical_version(i).name
|
164
181
|
end
|
165
182
|
end
|
166
183
|
end
|
@@ -226,15 +243,25 @@ class Chef
|
|
226
243
|
@available_version[index]
|
227
244
|
end
|
228
245
|
|
246
|
+
def magical_version(index)
|
247
|
+
@magical_version ||= []
|
248
|
+
@magical_version[index] ||= if new_resource.source
|
249
|
+
python_helper.package_query(:whatinstalled, available_version(index).name, version: safe_version_array[index], arch: safe_arch_array[index], options: options)
|
250
|
+
else
|
251
|
+
python_helper.package_query(:whatinstalled, package_name_array[index], version: safe_version_array[index], arch: safe_arch_array[index], options: options)
|
252
|
+
end
|
253
|
+
@magical_version[index]
|
254
|
+
end
|
255
|
+
|
229
256
|
# @return Array<Version>
|
230
|
-
def
|
231
|
-
@
|
232
|
-
@
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
@
|
257
|
+
def current_version(index)
|
258
|
+
@current_version ||= []
|
259
|
+
@current_version[index] ||= if new_resource.source
|
260
|
+
python_helper.package_query(:whatinstalled, available_version(index).name, arch: safe_arch_array[index], options: options)
|
261
|
+
else
|
262
|
+
python_helper.package_query(:whatinstalled, package_name_array[index], arch: safe_arch_array[index], options: options)
|
263
|
+
end
|
264
|
+
@current_version[index]
|
238
265
|
end
|
239
266
|
|
240
267
|
def flushcache
|
@@ -107,7 +107,7 @@ class Chef
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
action :install do
|
110
|
+
action :install, description: "Install a package. If a version is specified, install the specified version of the package." do
|
111
111
|
unless target_version_array.any?
|
112
112
|
logger.debug("#{new_resource} is already installed - nothing to do")
|
113
113
|
return
|
@@ -136,7 +136,7 @@ class Chef
|
|
136
136
|
|
137
137
|
private :install_description
|
138
138
|
|
139
|
-
action :upgrade do
|
139
|
+
action :upgrade, description: "Install a package and ensure that a package is the latest version." do
|
140
140
|
unless target_version_array.any?
|
141
141
|
logger.debug("#{new_resource} no versions to upgrade - nothing to do")
|
142
142
|
return
|
@@ -167,7 +167,7 @@ class Chef
|
|
167
167
|
|
168
168
|
private :upgrade_description
|
169
169
|
|
170
|
-
action :remove do
|
170
|
+
action :remove, description: "Remove a package." do
|
171
171
|
if removing_package?
|
172
172
|
description = new_resource.version ? "version #{new_resource.version} of " : ""
|
173
173
|
converge_by("remove #{description}package #{current_resource.package_name}") do
|
@@ -202,7 +202,7 @@ class Chef
|
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
action :purge do
|
205
|
+
action :purge, description: "Purge a package. This action typically removes the configuration files as well as the package." do
|
206
206
|
if removing_package?
|
207
207
|
description = new_resource.version ? "version #{new_resource.version} of" : ""
|
208
208
|
converge_by("purge #{description} package #{current_resource.package_name}") do
|
data/lib/chef/provider.rb
CHANGED
@@ -35,7 +35,6 @@ class Chef
|
|
35
35
|
attr_accessor :after_resource
|
36
36
|
attr_accessor :run_context
|
37
37
|
|
38
|
-
attr_reader :recipe_name
|
39
38
|
attr_reader :logger
|
40
39
|
|
41
40
|
include Chef::Mixin::WhyRun
|
@@ -174,6 +173,10 @@ class Chef
|
|
174
173
|
new_resource.cookbook_name
|
175
174
|
end
|
176
175
|
|
176
|
+
def recipe_name
|
177
|
+
new_resource.recipe_name
|
178
|
+
end
|
179
|
+
|
177
180
|
# hook that subclasses can use to do lazy validation for where properties aren't flexible enough
|
178
181
|
def check_resource_semantics!; end
|
179
182
|
|
data/lib/chef/providers.rb
CHANGED
@@ -108,7 +108,6 @@ require_relative "provider/group/groupadd"
|
|
108
108
|
require_relative "provider/group/groupmod"
|
109
109
|
require_relative "provider/group/pw"
|
110
110
|
require_relative "provider/group/solaris"
|
111
|
-
require_relative "provider/group/suse"
|
112
111
|
require_relative "provider/group/usermod"
|
113
112
|
require_relative "provider/group/windows"
|
114
113
|
|
@@ -43,7 +43,7 @@ class Chef
|
|
43
43
|
**Install multiple packages at once**:
|
44
44
|
|
45
45
|
```ruby
|
46
|
-
apt_package %(package1 package2 package3)
|
46
|
+
apt_package %w(package1 package2 package3)
|
47
47
|
```
|
48
48
|
|
49
49
|
**Install without using recommend packages as a dependency**:
|
@@ -55,7 +55,7 @@ class Chef
|
|
55
55
|
```
|
56
56
|
DOC
|
57
57
|
|
58
|
-
description "Use the **apt_package** resource to manage packages on Debian and
|
58
|
+
description "Use the **apt_package** resource to manage packages on Debian, Ubuntu, and other platforms that use the APT package system."
|
59
59
|
|
60
60
|
property :default_release, String,
|
61
61
|
description: "The default release. For example: `stable`.",
|
@@ -97,7 +97,6 @@ class Chef
|
|
97
97
|
data_collector_token 'TEST_TOKEN_TEST'
|
98
98
|
end
|
99
99
|
```
|
100
|
-
|
101
100
|
DOC
|
102
101
|
|
103
102
|
# @todo policy_file or policy_group being set requires the other to be set so enforce that.
|
@@ -243,11 +242,11 @@ class Chef
|
|
243
242
|
description: "Additional text to add at the bottom of the client.rb config. This can be used to run custom Ruby or to add less common config options"
|
244
243
|
|
245
244
|
property :data_collector_server_url, String,
|
246
|
-
description: "The data collector
|
245
|
+
description: "The data collector URL (typically automate) to send node, converge, and compliance data. Note: If possible, use Chef Infra Server to do all data collection reporting, as this removes the need to distribute tokens to individual nodes.",
|
247
246
|
introduced: "17.8"
|
248
247
|
|
249
248
|
property :data_collector_token, String,
|
250
|
-
description: "The data collector token to interact with the data collector server
|
249
|
+
description: "The data collector token to interact with the data collector server URL (Automate). Note: If possible, use Chef Infra Server to do all data collection reporting, as this removes the need to distribute tokens to individual nodes.",
|
251
250
|
introduced: "17.8"
|
252
251
|
|
253
252
|
action :create, description: "Create a client.rb config file for configuring #{ChefUtils::Dist::Infra::PRODUCT}." do
|
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
|
26
26
|
provides :chocolatey_package
|
27
27
|
|
28
|
-
description "Use the **chocolatey_package** resource to manage packages using Chocolatey on the Microsoft Windows platform. Note: The Chocolatey package manager is not installed on Windows by default. You will need to install it prior to using this resource by adding the [
|
28
|
+
description "Use the **chocolatey_package** resource to manage packages using the Chocolatey package manager on the Microsoft Windows platform. Note: The Chocolatey package manager is not installed on Windows by default. You will need to install it prior to using this resource by adding the [chocolatey cookbook](https://supermarket.chef.io/cookbooks/chocolatey/) to your node's run list. Warning: The **chocolatey_package** resource must be specified as `chocolatey_package` and cannot be shortened to `package` in a recipe."
|
29
29
|
introduced "12.7"
|
30
30
|
examples <<~DOC
|
31
31
|
**Install a Chocolatey package**:
|
@@ -73,9 +73,9 @@ class Chef
|
|
73
73
|
coerce: proc { |x| [x].flatten }
|
74
74
|
|
75
75
|
# In the choco if we have the feature useEnhancedExitCodes turned on, then choco will provide enhanced exit codes(2: no results).
|
76
|
-
# Choco exit codes https://chocolatey.org/
|
76
|
+
# Choco exit codes https://docs.chocolatey.org/en-us/choco/commands/info#exit-codes
|
77
77
|
property :returns, [Integer, Array],
|
78
|
-
description: "The exit code(s) returned
|
78
|
+
description: "The exit code(s) returned by the `choco` command that indicate a successful action. See [Chocolatey Exit Codes](https://docs.chocolatey.org/en-us/choco/commands/info#exit-codes) for a complete list of exit codes used by Chocolatey.",
|
79
79
|
default: [ 0, 2 ], desired_state: false,
|
80
80
|
introduced: "12.18"
|
81
81
|
end
|
@@ -20,6 +20,7 @@
|
|
20
20
|
require_relative "../../resource"
|
21
21
|
require_relative "../helpers/cron_validations"
|
22
22
|
require_relative "../../provider/cron" # do not remove. we actually need this below
|
23
|
+
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
23
24
|
|
24
25
|
class Chef
|
25
26
|
class Resource
|
@@ -30,7 +31,80 @@ class Chef
|
|
30
31
|
|
31
32
|
provides :cron
|
32
33
|
|
33
|
-
description "Use the **cron** resource to manage cron entries for time-based job scheduling. Properties for a schedule will default to * if not provided. The cron resource requires access to a crontab program, typically cron."
|
34
|
+
description "Use the **cron** resource to manage cron entries for time-based job scheduling. Properties for a schedule will default to * if not provided. The cron resource requires access to a crontab program, typically cron. Warning: The cron resource should only be used to modify an entry in a crontab file. The `cron_d` resource directly manages `cron.d` files. This resource ships in #{ChefUtils::Dist::Infra::PRODUCT} 14.4 or later and can also be found in the [cron](https://github.com/chef-cookbooks/cron) cookbook) for previous #{ChefUtils::Dist::Infra::PRODUCT} releases."
|
35
|
+
|
36
|
+
examples <<~'DOC'
|
37
|
+
**Run a program at a specified interval**
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
cron 'noop' do
|
41
|
+
hour '5'
|
42
|
+
minute '0'
|
43
|
+
command '/bin/true'
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
**Run an entry if a folder exists**
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
cron 'ganglia_tomcat_thread_max' do
|
51
|
+
command "/usr/bin/gmetric
|
52
|
+
-n 'tomcat threads max'
|
53
|
+
-t uint32
|
54
|
+
-v '/usr/local/bin/tomcat-stat --thread-max'"
|
55
|
+
only_if { ::File.exist?('/home/jboss') }
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
**Run every Saturday, 8:00 AM**
|
60
|
+
|
61
|
+
The following example shows a schedule that will run every hour at 8:00 each Saturday morning, and will then send an email to “admin@example.com” after each run.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
cron 'name_of_cron_entry' do
|
65
|
+
minute '0'
|
66
|
+
hour '8'
|
67
|
+
weekday '6'
|
68
|
+
mailto 'admin@example.com'
|
69
|
+
action :create
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
**Run once a week**
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
cron 'cookbooks_report' do
|
77
|
+
minute '0'
|
78
|
+
hour '0'
|
79
|
+
weekday '1'
|
80
|
+
user 'chefio'
|
81
|
+
mailto 'sysadmin@example.com'
|
82
|
+
home '/srv/supermarket/shared/system'
|
83
|
+
command %W{
|
84
|
+
cd /srv/supermarket/current &&
|
85
|
+
env RUBYLIB="/srv/supermarket/current/lib"
|
86
|
+
RAILS_ASSET_ID=`git rev-parse HEAD` RAILS_ENV="#{rails_env}"
|
87
|
+
bundle exec rake cookbooks_report
|
88
|
+
}.join(' ')
|
89
|
+
action :create
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
**Run only in November**
|
94
|
+
|
95
|
+
The following example shows a schedule that will run at 8:00 PM, every weekday (Monday through Friday), but only in November:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
cron 'name_of_cron_entry' do
|
99
|
+
minute '0'
|
100
|
+
hour '20'
|
101
|
+
day '*'
|
102
|
+
month '11'
|
103
|
+
weekday '1-5'
|
104
|
+
action :create
|
105
|
+
end
|
106
|
+
```
|
107
|
+
DOC
|
34
108
|
|
35
109
|
state_attrs :minute, :hour, :day, :month, :weekday, :user
|
36
110
|
|
@@ -18,6 +18,7 @@
|
|
18
18
|
require_relative "../../resource"
|
19
19
|
require_relative "../helpers/cron_validations"
|
20
20
|
require "shellwords" unless defined?(Shellwords)
|
21
|
+
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
21
22
|
|
22
23
|
class Chef
|
23
24
|
class Resource
|
@@ -29,7 +30,7 @@ class Chef
|
|
29
30
|
provides :cron_d
|
30
31
|
|
31
32
|
introduced "14.4"
|
32
|
-
description "Use the **cron_d** resource to manage cron job files in the `/etc/cron.d` directory.
|
33
|
+
description "Use the **cron_d** resource to manage cron job files in the `/etc/cron.d` directory. Warning: #{ChefUtils::Dist::Infra::PRODUCT} also ships with the **cron** resource for managing the monolithic `/etc/crontab` file on platforms that lack cron.d support. See the [cron resource](/resources/cron/) for information on using that resource."
|
33
34
|
examples <<~DOC
|
34
35
|
**Run a program on the fifth hour of the day**
|
35
36
|
|
@@ -41,10 +41,6 @@ class Chef
|
|
41
41
|
property :url, String,
|
42
42
|
description: "The URL of the tap."
|
43
43
|
|
44
|
-
property :full, [TrueClass, FalseClass],
|
45
|
-
description: "Perform a full clone on the tap, as opposed to a shallow clone.",
|
46
|
-
default: false
|
47
|
-
|
48
44
|
property :homebrew_path, String,
|
49
45
|
description: "The path to the Homebrew binary.",
|
50
46
|
default: "/usr/local/bin/brew"
|
@@ -25,10 +25,10 @@ class Chef
|
|
25
25
|
|
26
26
|
provides :powershell_package_source
|
27
27
|
|
28
|
-
description "Use the **powershell_package_source** resource to register a PowerShell package source and a Powershell package provider. There are
|
28
|
+
description "Use the **powershell_package_source** resource to register a PowerShell package source and a Powershell package provider. There are two distinct objects we care about here. The first is a package source like a PowerShell repository or a NuGet Source. The second object is a provider that PowerShell uses to get to that source with, like PowerShellGet, NuGet, Chocolatey, etc."
|
29
29
|
introduced "14.3"
|
30
30
|
examples <<~DOC
|
31
|
-
**Add a new
|
31
|
+
**Add a new PowerShell repository that is not trusted and which requires credentials to connect to**:
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
powershell_package_source 'PowerShellModules' do
|
@@ -43,7 +43,7 @@ class Chef
|
|
43
43
|
end
|
44
44
|
```
|
45
45
|
|
46
|
-
**Add a new
|
46
|
+
**Add a new package source that uses Chocolatey as the package provider**:
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
powershell_package_source 'PowerShellModules' do
|
@@ -56,7 +56,7 @@ class Chef
|
|
56
56
|
end
|
57
57
|
```
|
58
58
|
|
59
|
-
**Add a new PowerShell
|
59
|
+
**Add a new PowerShell script source that is trusted**:
|
60
60
|
|
61
61
|
```ruby
|
62
62
|
powershell_package_source 'MyDodgyScript' do
|
@@ -68,7 +68,7 @@ class Chef
|
|
68
68
|
end
|
69
69
|
```
|
70
70
|
|
71
|
-
**Update
|
71
|
+
**Update an existing PowerShell repository to make it trusted**:
|
72
72
|
|
73
73
|
```ruby
|
74
74
|
powershell_package_source 'MyPSModule' do
|
@@ -137,7 +137,7 @@ class Chef
|
|
137
137
|
description: "The location where scripts will be published to for this source. Only valid if the provider is `PowerShellGet`."
|
138
138
|
|
139
139
|
property :trusted, [TrueClass, FalseClass],
|
140
|
-
description: "Whether or not to trust packages from this source. Used when creating a
|
140
|
+
description: "Whether or not to trust packages from this source. Used when creating a non-PowerShell repository package source.",
|
141
141
|
default: false
|
142
142
|
|
143
143
|
property :user, String,
|
@@ -151,7 +151,7 @@ class Chef
|
|
151
151
|
property :provider_name, String,
|
152
152
|
equal_to: %w{ Programs msi NuGet msu PowerShellGet psl chocolatey winget },
|
153
153
|
validation_message: "The following providers are supported: 'Programs', 'msi', 'NuGet', 'msu', 'PowerShellGet', 'psl', 'chocolatey' or 'winget'",
|
154
|
-
description: "The package management provider for the package source. The default is PowerShellGet
|
154
|
+
description: "The package management provider for the package source. The default is `PowerShellGet`. Only change this option in specific use cases.",
|
155
155
|
default: "NuGet"
|
156
156
|
|
157
157
|
load_current_value do
|
@@ -202,7 +202,7 @@ class Chef
|
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
action :set, description: "Updates an existing
|
205
|
+
action :set, description: "Updates an existing PowerShell repository or package source." do
|
206
206
|
package_details = get_package_source_details
|
207
207
|
output = package_details.result
|
208
208
|
if output == "PSRepository"
|
@@ -80,7 +80,7 @@ class Chef
|
|
80
80
|
introduced: "15.9"
|
81
81
|
|
82
82
|
property :server_url, String,
|
83
|
-
description: "The hostname of the subscription service to use. The default is
|
83
|
+
description: "The hostname of the subscription service to use. The default is Customer Portal Subscription Management, subscription.rhn.redhat.com. If you do not use this option, the system registers with Customer Portal Subscription Management.",
|
84
84
|
introduced: "17.8"
|
85
85
|
|
86
86
|
property :base_url, String,
|
@@ -88,12 +88,12 @@ class Chef
|
|
88
88
|
introduced: "17.8"
|
89
89
|
|
90
90
|
property :service_level, String,
|
91
|
-
description: "Sets the service level to use for subscriptions on the registering machine. This is only used with the auto_attach option.",
|
91
|
+
description: "Sets the service level to use for subscriptions on the registering machine. This is only used with the `auto_attach` option.",
|
92
92
|
introduced: "17.8"
|
93
93
|
|
94
94
|
property :release,
|
95
95
|
[Float, String],
|
96
|
-
description: "Sets the operating system minor release to use for subscriptions for the system. Products and updates are limited to the specified minor release version. This is used only used with the auto_attach option. For example, `release '6.4'` will append `--release=6.4` to the register command.",
|
96
|
+
description: "Sets the operating system minor release to use for subscriptions for the system. Products and updates are limited to the specified minor release version. This is used only used with the `auto_attach` option. For example, `release '6.4'` will append `--release=6.4` to the register command.",
|
97
97
|
introduced: "17.8"
|
98
98
|
|
99
99
|
action :register, description: "Register the node with RHSM." do
|