chef 16.7.61-universal-mingw32 → 16.9.20-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -5
- data/README.md +2 -2
- data/chef.gemspec +12 -2
- data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.Wrapper.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
- data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
- data/distro/ruby_bin_folder/x86/Chef.PowerShell.dll +0 -0
- data/distro/ruby_bin_folder/x86/Chef.Powershell.Wrapper.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
- data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
- data/lib/chef/application/base.rb +1 -1
- data/lib/chef/client.rb +3 -0
- data/lib/chef/compliance/default_attributes.rb +93 -0
- data/lib/chef/compliance/fetcher/automate.rb +69 -0
- data/lib/chef/compliance/fetcher/chef_server.rb +134 -0
- data/lib/chef/compliance/reporter/automate.rb +201 -0
- data/lib/chef/compliance/reporter/chef_server_automate.rb +94 -0
- data/lib/chef/compliance/reporter/compliance_enforcer.rb +20 -0
- data/lib/chef/compliance/reporter/json_file.rb +19 -0
- data/lib/chef/compliance/runner.rb +262 -0
- data/lib/chef/cookbook_manifest.rb +1 -0
- data/lib/chef/encrypted_data_bag_item/assertions.rb +1 -1
- data/lib/chef/exceptions.rb +4 -0
- data/lib/chef/http/ssl_policies.rb +33 -14
- data/lib/chef/knife/bootstrap/train_connector.rb +1 -1
- data/lib/chef/knife/core/formatting_options.rb +49 -0
- data/lib/chef/knife/core/node_presenter.rb +0 -25
- data/lib/chef/knife/core/status_presenter.rb +1 -26
- data/lib/chef/knife/core/ui.rb +4 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +1 -1
- data/lib/chef/knife/node_show.rb +2 -1
- data/lib/chef/knife/search.rb +2 -1
- data/lib/chef/knife/ssh.rb +3 -1
- data/lib/chef/knife/status.rb +8 -11
- data/lib/chef/mixin/powershell_exec.rb +3 -1
- data/lib/chef/platform/query_helpers.rb +4 -4
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/powershell.rb +2 -0
- data/lib/chef/provider/dsc_resource.rb +12 -24
- data/lib/chef/provider/dsc_script.rb +16 -20
- data/lib/chef/provider/git.rb +5 -5
- data/lib/chef/provider/package.rb +53 -19
- data/lib/chef/provider/package/dnf.rb +39 -12
- data/lib/chef/provider/package/dnf/dnf_helper.py +18 -5
- data/lib/chef/provider/package/dnf/python_helper.rb +6 -6
- data/lib/chef/provider/package/freebsd/pkgng.rb +3 -1
- data/lib/chef/provider/yum_repository.rb +2 -2
- data/lib/chef/resource/chef_client_config.rb +1 -1
- data/lib/chef/resource/chef_gem.rb +2 -2
- data/lib/chef/resource/cron/cron_d.rb +1 -0
- data/lib/chef/resource/dsc_script.rb +8 -1
- data/lib/chef/resource/file.rb +1 -1
- data/lib/chef/resource/gem_package.rb +2 -2
- data/lib/chef/resource/homebrew_cask.rb +3 -3
- data/lib/chef/resource/hostname.rb +3 -3
- data/lib/chef/resource/http_request.rb +1 -1
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/mdadm.rb +2 -2
- data/lib/chef/resource/osx_profile.rb +7 -7
- data/lib/chef/resource/remote_directory.rb +1 -1
- data/lib/chef/resource/ruby.rb +1 -5
- data/lib/chef/resource/ruby_block.rb +1 -1
- data/lib/chef/resource/template.rb +2 -2
- data/lib/chef/resource/user/windows_user.rb +5 -0
- data/lib/chef/resource/windows_certificate.rb +9 -13
- data/lib/chef/resource/yum_repository.rb +5 -0
- data/lib/chef/resource_collection/resource_set.rb +1 -1
- data/lib/chef/util/dsc/configuration_generator.rb +52 -11
- data/lib/chef/util/dsc/lcm_output_parser.rb +3 -4
- data/lib/chef/util/dsc/local_configuration_manager.rb +17 -14
- data/lib/chef/util/dsc/resource_store.rb +5 -11
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +4 -0
- data/spec/data/rubygems.org/latest_specs.4.8.gz +0 -0
- data/spec/data/rubygems.org/nonexistent_gem +0 -0
- data/spec/data/rubygems.org/sexp_processor +0 -0
- data/spec/data/rubygems.org/sexp_processor-4.15.1.gemspec.rz +0 -0
- data/spec/data/ssl/binary/chef-rspec-der.cert +0 -0
- data/spec/data/ssl/binary/chef-rspec-der.key +0 -0
- data/spec/functional/resource/dnf_package_spec.rb +319 -16
- data/spec/functional/resource/dsc_script_spec.rb +3 -6
- data/spec/functional/resource/windows_certificate_spec.rb +204 -384
- data/spec/integration/client/client_spec.rb +2 -1
- data/spec/integration/compliance/compliance_spec.rb +81 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/client_spec.rb +1 -0
- data/spec/unit/compliance/fetcher/automate_spec.rb +134 -0
- data/spec/unit/compliance/fetcher/chef_server_spec.rb +93 -0
- data/spec/unit/compliance/reporter/automate_spec.rb +427 -0
- data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +177 -0
- data/spec/unit/compliance/reporter/compliance_enforcer_spec.rb +48 -0
- data/spec/unit/compliance/runner_spec.rb +167 -0
- data/spec/unit/http/ssl_policies_spec.rb +107 -68
- data/spec/unit/knife/bootstrap_spec.rb +5 -17
- data/spec/unit/knife/core/node_editor_spec.rb +1 -1
- data/spec/unit/knife/core/status_presenter_spec.rb +54 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +0 -7
- data/spec/unit/mixin/powershell_exec_spec.rb +1 -1
- data/spec/unit/platform/query_helpers_spec.rb +11 -12
- data/spec/unit/provider/dsc_resource_spec.rb +10 -27
- data/spec/unit/provider/dsc_script_spec.rb +1 -1
- data/spec/unit/provider/mount/windows_spec.rb +1 -0
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
- data/spec/unit/provider/package/rubygems_spec.rb +39 -7
- data/spec/unit/provider/systemd_unit_spec.rb +1 -1
- data/spec/unit/resource/user/windows_user_spec.rb +36 -0
- data/spec/unit/resource/windows_certificate_spec.rb +12 -0
- data/spec/unit/util/dsc/configuration_generator_spec.rb +79 -0
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +27 -35
- metadata +55 -18
- data/lib/chef/util/powershell/cmdlet.rb +0 -169
- data/lib/chef/util/powershell/cmdlet_result.rb +0 -61
- data/spec/data/trusted_certs_empty/.gitkeep +0 -0
- data/spec/data/trusted_certs_empty/README.md +0 -1
- data/spec/functional/util/powershell/cmdlet_spec.rb +0 -111
- data/spec/scripts/ssl-serve.rb +0 -47
- data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
data/lib/chef/provider/git.rb
CHANGED
@@ -68,9 +68,9 @@ class Chef
|
|
68
68
|
a.assertion { !(new_resource.revision =~ %r{^origin/}) }
|
69
69
|
a.failure_message Chef::Exceptions::InvalidRemoteGitReference,
|
70
70
|
"Deploying remote branches is not supported. " +
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
"Specify the remote branch as a local branch for " +
|
72
|
+
"the git repository you're deploying from " +
|
73
|
+
"(ie: '#{new_resource.revision.gsub("origin/", "")}' rather than '#{new_resource.revision}')."
|
74
74
|
end
|
75
75
|
|
76
76
|
requirements.assert(:all_actions) do |a|
|
@@ -80,8 +80,8 @@ class Chef
|
|
80
80
|
a.assertion { !target_revision.nil? }
|
81
81
|
a.failure_message Chef::Exceptions::UnresolvableGitReference,
|
82
82
|
"Unable to parse SHA reference for '#{new_resource.revision}' in repository '#{new_resource.repository}'. " +
|
83
|
-
|
84
|
-
|
83
|
+
"Verify your (case-sensitive) repository URL and revision.\n" +
|
84
|
+
"`git ls-remote '#{new_resource.repository}' '#{rev_search_pattern}'` output: #{@resolved_reference}"
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -28,14 +28,41 @@ class Chef
|
|
28
28
|
class Package < Chef::Provider
|
29
29
|
extend Chef::Mixin::SubclassDirective
|
30
30
|
|
31
|
-
# subclasses declare this if they want all their arguments as arrays of packages and names
|
31
|
+
# subclasses declare this if they want all their arguments as arrays of packages and names.
|
32
|
+
# any new packages using this should also use allow_nils below.
|
33
|
+
#
|
32
34
|
subclass_directive :use_multipackage_api
|
33
|
-
|
35
|
+
|
36
|
+
# subclasses declare this if they want sources (filenames) pulled from their package names.
|
37
|
+
# this is for package providers that take a path into the filesystem (rpm, dpkg).
|
38
|
+
#
|
34
39
|
subclass_directive :use_package_name_for_source
|
40
|
+
|
35
41
|
# keeps package_names_for_targets and versions_for_targets indexed the same as package_name at
|
36
|
-
# the cost of having the subclass needing to deal with nils
|
42
|
+
# the cost of having the subclass needing to deal with nils. all providers are encouraged to
|
43
|
+
# migrate to using this as it simplifies dealing with package aliases in subclasses.
|
44
|
+
#
|
37
45
|
subclass_directive :allow_nils
|
38
46
|
|
47
|
+
# subclasses that implement complex pattern matching using constraints, particularly the yum and
|
48
|
+
# dnf classes, should filter the installed version against the desired version constraint and
|
49
|
+
# return nil if it does not match. this means that 'nil' does not mean that no version of the
|
50
|
+
# package is installed, but that the installed version does not satisfy the desired constraints.
|
51
|
+
# (the package plus the constraints are not installed)
|
52
|
+
#
|
53
|
+
# [ this may arguably be useful for all package providers and it greatly simplifies the logic
|
54
|
+
# in the superclass that gets executed, so maybe this should always be used now? ]
|
55
|
+
#
|
56
|
+
# note that when using this feature that the current_resource.version must be loaded with the
|
57
|
+
# correct currently installed version, without doing the filtering -- for reporting and for
|
58
|
+
# correctly displaying version upgrades. that means there are 3 different arrays which must be
|
59
|
+
# loaded by the subclass: candidate_version, magic_version and current_resource.version.
|
60
|
+
#
|
61
|
+
# NOTE: magic_version is a terrible name, but I couldn't think of anything better, at least this
|
62
|
+
# way it stands out clearly.
|
63
|
+
#
|
64
|
+
subclass_directive :use_magic_version
|
65
|
+
|
39
66
|
#
|
40
67
|
# Hook that subclasses use to populate the candidate_version(s)
|
41
68
|
#
|
@@ -414,19 +441,21 @@ class Chef
|
|
414
441
|
each_package do |package_name, new_version, current_version, candidate_version|
|
415
442
|
case action
|
416
443
|
when :upgrade
|
417
|
-
if
|
418
|
-
#
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
444
|
+
if current_version.nil?
|
445
|
+
# with use_magic_version there may be a package installed, but it fails the user's
|
446
|
+
# requested new_resource.version constraints
|
447
|
+
logger.trace("#{new_resource} has no existing installed version. Installing install #{candidate_version}")
|
448
|
+
target_version_array.push(candidate_version)
|
449
|
+
elsif version_equals?(current_version, new_version)
|
450
|
+
# this is a short-circuit to avoid needing to (expensively) query the candidate_version which must come later
|
451
|
+
logger.trace("#{new_resource} #{package_name} #{new_version} is already installed")
|
423
452
|
target_version_array.push(nil)
|
424
453
|
elsif candidate_version.nil?
|
425
454
|
logger.trace("#{new_resource} #{package_name} has no candidate_version to upgrade to")
|
426
455
|
target_version_array.push(nil)
|
427
|
-
elsif current_version
|
428
|
-
logger.trace("#{new_resource}
|
429
|
-
target_version_array.push(
|
456
|
+
elsif version_equals?(current_version, candidate_version)
|
457
|
+
logger.trace("#{new_resource} #{package_name} #{candidate_version} is already installed")
|
458
|
+
target_version_array.push(nil)
|
430
459
|
elsif !allow_downgrade && version_compare(current_version, candidate_version) == 1
|
431
460
|
logger.trace("#{new_resource} #{package_name} has installed version #{current_version}, which is newer than available version #{candidate_version}. Skipping...)")
|
432
461
|
target_version_array.push(nil)
|
@@ -436,21 +465,20 @@ class Chef
|
|
436
465
|
end
|
437
466
|
|
438
467
|
when :install
|
439
|
-
if new_version
|
468
|
+
if new_version && !use_magic_version?
|
440
469
|
if version_requirement_satisfied?(current_version, new_version)
|
441
470
|
logger.trace("#{new_resource} #{package_name} #{current_version} satisfies #{new_version} requirement")
|
442
471
|
target_version_array.push(nil)
|
443
472
|
elsif current_version && !allow_downgrade && version_compare(current_version, new_version) == 1
|
444
473
|
logger.warn("#{new_resource} #{package_name} has installed version #{current_version}, which is newer than available version #{new_version}. Skipping...)")
|
445
474
|
target_version_array.push(nil)
|
446
|
-
elsif version_equals?(current_version, candidate_version)
|
447
|
-
logger.trace("#{new_resource} #{package_name} #{candidate_version} is already installed")
|
448
|
-
target_version_array.push(nil)
|
449
475
|
else
|
450
476
|
logger.trace("#{new_resource} #{package_name} #{current_version} needs updating to #{new_version}")
|
451
477
|
target_version_array.push(new_version)
|
452
478
|
end
|
453
479
|
elsif current_version.nil?
|
480
|
+
# with use_magic_version there may be a package installed, but it fails the user's
|
481
|
+
# requested new_resource.version constraints
|
454
482
|
logger.trace("#{new_resource} #{package_name} not installed, installing #{candidate_version}")
|
455
483
|
target_version_array.push(candidate_version)
|
456
484
|
else
|
@@ -511,8 +539,14 @@ class Chef
|
|
511
539
|
each_package do |package_name, new_version, current_version, candidate_version|
|
512
540
|
next if new_version.nil? || current_version.nil?
|
513
541
|
|
514
|
-
if
|
515
|
-
|
542
|
+
if use_magic_version?
|
543
|
+
if !magic_version && candidate_version.nil?
|
544
|
+
missing.push(package_name)
|
545
|
+
end
|
546
|
+
else
|
547
|
+
if !version_requirement_satisfied?(current_version, new_version) && candidate_version.nil?
|
548
|
+
missing.push(package_name)
|
549
|
+
end
|
516
550
|
end
|
517
551
|
end
|
518
552
|
missing
|
@@ -525,7 +559,7 @@ class Chef
|
|
525
559
|
def each_package
|
526
560
|
package_name_array.each_with_index do |package_name, i|
|
527
561
|
candidate_version = candidate_version_array[i]
|
528
|
-
current_version = current_version_array[i]
|
562
|
+
current_version = use_magic_version? ? magic_version[i] : current_version_array[i]
|
529
563
|
new_version = new_version_array[i]
|
530
564
|
yield package_name, new_version, current_version, candidate_version
|
531
565
|
end
|
@@ -34,6 +34,7 @@ class Chef
|
|
34
34
|
allow_nils
|
35
35
|
use_multipackage_api
|
36
36
|
use_package_name_for_source
|
37
|
+
use_magic_version
|
37
38
|
|
38
39
|
# all rhel variants >= 8 will use DNF
|
39
40
|
provides :package, platform_family: "rhel", platform_version: ">= 8"
|
@@ -71,6 +72,16 @@ class Chef
|
|
71
72
|
current_resource
|
72
73
|
end
|
73
74
|
|
75
|
+
def load_after_resource
|
76
|
+
# force the installed version array to repopulate
|
77
|
+
@current_version = []
|
78
|
+
@after_resource = Chef::Resource::DnfPackage.new(new_resource.name)
|
79
|
+
after_resource.package_name(new_resource.package_name)
|
80
|
+
after_resource.version(get_current_versions)
|
81
|
+
|
82
|
+
after_resource
|
83
|
+
end
|
84
|
+
|
74
85
|
def define_resource_requirements
|
75
86
|
requirements.assert(:install, :upgrade, :remove, :purge) do |a|
|
76
87
|
a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
|
@@ -87,9 +98,15 @@ class Chef
|
|
87
98
|
end
|
88
99
|
end
|
89
100
|
|
101
|
+
def magic_version
|
102
|
+
package_name_array.each_with_index.map do |pkg, i|
|
103
|
+
magical_version(i).version_with_arch
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
90
107
|
def get_current_versions
|
91
108
|
package_name_array.each_with_index.map do |pkg, i|
|
92
|
-
|
109
|
+
current_version(i).version_with_arch
|
93
110
|
end
|
94
111
|
end
|
95
112
|
|
@@ -107,7 +124,7 @@ class Chef
|
|
107
124
|
alias upgrade_package install_package
|
108
125
|
|
109
126
|
def remove_package(names, versions)
|
110
|
-
resolved_names = names.each_with_index.map { |name, i|
|
127
|
+
resolved_names = names.each_with_index.map { |name, i| magical_version(i).to_s unless name.nil? }
|
111
128
|
dnf(options, "-y", "remove", resolved_names)
|
112
129
|
flushcache
|
113
130
|
end
|
@@ -137,10 +154,10 @@ class Chef
|
|
137
154
|
def resolved_package_lock_names(names)
|
138
155
|
names.each_with_index.map do |name, i|
|
139
156
|
unless name.nil?
|
140
|
-
if
|
157
|
+
if magical_version(i).version.nil?
|
141
158
|
available_version(i).name
|
142
159
|
else
|
143
|
-
|
160
|
+
magical_version(i).name
|
144
161
|
end
|
145
162
|
end
|
146
163
|
end
|
@@ -205,14 +222,24 @@ class Chef
|
|
205
222
|
end
|
206
223
|
|
207
224
|
# @return [Array<Version>]
|
208
|
-
def
|
209
|
-
@
|
210
|
-
@
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
@
|
225
|
+
def magical_version(index)
|
226
|
+
@magical_version ||= []
|
227
|
+
@magical_version[index] ||= if new_resource.source
|
228
|
+
python_helper.package_query(:whatinstalled, available_version(index).name, version: safe_version_array[index], arch: safe_arch_array[index], options: options)
|
229
|
+
else
|
230
|
+
python_helper.package_query(:whatinstalled, package_name_array[index], version: safe_version_array[index], arch: safe_arch_array[index], options: options)
|
231
|
+
end
|
232
|
+
@magical_version[index]
|
233
|
+
end
|
234
|
+
|
235
|
+
def current_version(index)
|
236
|
+
@current_version ||= []
|
237
|
+
@current_version[index] ||= if new_resource.source
|
238
|
+
python_helper.package_query(:whatinstalled, available_version(index).name, arch: safe_arch_array[index], options: options)
|
239
|
+
else
|
240
|
+
python_helper.package_query(:whatinstalled, package_name_array[index], arch: safe_arch_array[index], options: options)
|
241
|
+
end
|
242
|
+
@current_version[index]
|
216
243
|
end
|
217
244
|
|
218
245
|
# cache flushing is accomplished by simply restarting the python helper. this produces a roughly
|
@@ -98,14 +98,27 @@ def query(command):
|
|
98
98
|
q = q.available()
|
99
99
|
|
100
100
|
if 'epoch' in command:
|
101
|
-
|
101
|
+
# We assume that any glob is "*" so just omit the filter since the dnf libraries have no
|
102
|
+
# epoch__glob filter. That means "?" wildcards in epochs will fail. The workaround is to
|
103
|
+
# not use the version filter here but to put the version with all the globs in the package name.
|
104
|
+
if not dnf.util.is_glob_pattern(command['epoch']):
|
105
|
+
q = q.filterm(epoch=int(command['epoch']))
|
102
106
|
if 'version' in command:
|
103
|
-
|
107
|
+
if dnf.util.is_glob_pattern(command['version']):
|
108
|
+
q = q.filterm(version__glob=command['version'])
|
109
|
+
else:
|
110
|
+
q = q.filterm(version=command['version'])
|
104
111
|
if 'release' in command:
|
105
|
-
|
112
|
+
if dnf.util.is_glob_pattern(command['release']):
|
113
|
+
q = q.filterm(release__glob=command['release'])
|
114
|
+
else:
|
115
|
+
q = q.filterm(release=command['release'])
|
106
116
|
|
107
117
|
if 'arch' in command:
|
108
|
-
|
118
|
+
if dnf.util.is_glob_pattern(command['arch']):
|
119
|
+
q = q.filterm(arch__glob=command['arch'])
|
120
|
+
else:
|
121
|
+
q = q.filterm(arch=command['arch'])
|
109
122
|
|
110
123
|
# only apply the default arch query filter if it returns something
|
111
124
|
archq = q.filter(arch=[ 'noarch', hawkey.detect_arch() ])
|
@@ -170,4 +183,4 @@ try:
|
|
170
183
|
raise RuntimeError("bad command")
|
171
184
|
finally:
|
172
185
|
if base is not None:
|
173
|
-
base.
|
186
|
+
base.close()
|
@@ -42,13 +42,13 @@ class Chef
|
|
42
42
|
def dnf_command
|
43
43
|
# platform-python is used for system tools on RHEL 8 and is installed under /usr/libexec
|
44
44
|
@dnf_command ||= begin
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
cmd = which("platform-python", "python", "python3", "python2", "python2.7", extra_path: "/usr/libexec") do |f|
|
46
|
+
shell_out("#{f} -c 'import dnf'").exitstatus == 0
|
47
|
+
end
|
48
|
+
raise Chef::Exceptions::Package, "cannot find dnf libraries, you may need to use yum_package" unless cmd
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
"#{cmd} #{DNF_HELPER}"
|
51
|
+
end
|
52
52
|
end
|
53
53
|
|
54
54
|
def start
|
@@ -42,7 +42,9 @@ class Chef
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def current_installed_version
|
45
|
-
|
45
|
+
# pkgng up to version 1.15.99.7 returns 70 for pkg not found,
|
46
|
+
# later versions return 1
|
47
|
+
pkg_info = shell_out!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 1, 70])
|
46
48
|
pkg_info.stdout[/^Version +: (.+)$/, 1]
|
47
49
|
end
|
48
50
|
|
@@ -33,7 +33,7 @@ class Chef
|
|
33
33
|
def load_current_resource; end
|
34
34
|
|
35
35
|
action :create do
|
36
|
-
declare_resource(:template,
|
36
|
+
declare_resource(:template, ::File.join(new_resource.reposdir, "#{new_resource.repositoryid}.repo")) do
|
37
37
|
if template_available?(new_resource.source)
|
38
38
|
source new_resource.source
|
39
39
|
else
|
@@ -81,7 +81,7 @@ class Chef
|
|
81
81
|
only_if "yum repolist all | grep -P '^#{new_resource.repositoryid}([ \t]|$)'"
|
82
82
|
end
|
83
83
|
|
84
|
-
declare_resource(:file,
|
84
|
+
declare_resource(:file, ::File.join(new_resource.reposdir, "#{new_resource.repositoryid}.repo")) do
|
85
85
|
action :delete
|
86
86
|
notifies :create, "ruby_block[package-cache-reload-#{new_resource.repositoryid}]", :immediately
|
87
87
|
end
|
@@ -110,7 +110,7 @@ class Chef
|
|
110
110
|
property :config_directory, String,
|
111
111
|
description: "The directory to store the client.rb in.",
|
112
112
|
default: ChefConfig::Config.etc_chef_dir,
|
113
|
-
default_description: "`/etc/chef/` on *nix-like systems and `C
|
113
|
+
default_description: "`/etc/chef/` on *nix-like systems and `C:\\chef\\` on Windows"
|
114
114
|
|
115
115
|
property :user, String,
|
116
116
|
description: "The user that should own the client.rb file and the configuration directory if it needs to be created. Note: The configuration directory will not be created if it already exists, which allows you to further control the setup of that directory outside of this resource."
|
@@ -49,7 +49,7 @@ class Chef
|
|
49
49
|
|
50
50
|
To install a gem while #{ChefUtils::Dist::Infra::PRODUCT} is configuring the node (the converge phase), set the `compile_time` property to `false`:
|
51
51
|
```ruby
|
52
|
-
chef_gem '
|
52
|
+
chef_gem 'loofah' do
|
53
53
|
compile_time false
|
54
54
|
action :install
|
55
55
|
end
|
@@ -57,7 +57,7 @@ class Chef
|
|
57
57
|
|
58
58
|
To install a gem while the resource collection is being built (the compile phase), set the `compile_time` property to `true`:
|
59
59
|
```ruby
|
60
|
-
chef_gem '
|
60
|
+
chef_gem 'loofah' do
|
61
61
|
compile_time true
|
62
62
|
action :install
|
63
63
|
end
|
@@ -29,7 +29,14 @@ class Chef
|
|
29
29
|
unified_mode true
|
30
30
|
provides :dsc_script
|
31
31
|
|
32
|
-
description
|
32
|
+
description <<~DESC
|
33
|
+
Many DSC resources are comparable to built-in #{ChefUtils::Dist::Infra::PRODUCT} resources. For example, both DSC and #{ChefUtils::Dist::Infra::PRODUCT}
|
34
|
+
have file, package, and service resources. The dsc_script resource is most useful for those DSC resources that do not have a direct comparison to a
|
35
|
+
resource in #{ChefUtils::Dist::Infra::PRODUCT}, such as the Archive resource, a custom DSC resource, an existing DSC script that performs an important
|
36
|
+
task, and so on. Use the dsc_script resource to embed the code that defines a DSC configuration directly within a #{ChefUtils::Dist::Infra::PRODUCT} recipe.
|
37
|
+
|
38
|
+
Warning: The **dsc_script** resource may not be used with the 32 bit Chef Infra client. It must be executed from a 64 bit Chef Infra client.
|
39
|
+
DESC
|
33
40
|
|
34
41
|
default_action :run
|
35
42
|
|
data/lib/chef/resource/file.rb
CHANGED
@@ -32,7 +32,7 @@ class Chef
|
|
32
32
|
|
33
33
|
provides :file
|
34
34
|
|
35
|
-
description "Use the **file** resource to manage files directly on a node."
|
35
|
+
description "Use the **file** resource to manage files directly on a node. Note: Use the **cookbook_file** resource to copy a file from a cookbook's `/files` directory. Use the **template** resource to create a file based on a template in a cookbook's `/templates` directory. And use the **remote_file** resource to transfer a file to a node from a remote location."
|
36
36
|
|
37
37
|
if ChefUtils.windows?
|
38
38
|
# Use Windows rights instead of standard *nix permissions
|
@@ -60,7 +60,7 @@ class Chef
|
|
60
60
|
|
61
61
|
unless casked?
|
62
62
|
converge_by("install cask #{new_resource.cask_name} #{new_resource.options}") do
|
63
|
-
shell_out!("#{new_resource.homebrew_path} cask
|
63
|
+
shell_out!("#{new_resource.homebrew_path} install --cask #{new_resource.cask_name} #{new_resource.options}",
|
64
64
|
user: new_resource.owner,
|
65
65
|
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
|
66
66
|
cwd: ::Dir.home(new_resource.owner))
|
@@ -75,7 +75,7 @@ class Chef
|
|
75
75
|
|
76
76
|
if casked?
|
77
77
|
converge_by("uninstall cask #{new_resource.cask_name}") do
|
78
|
-
shell_out!("#{new_resource.homebrew_path} cask
|
78
|
+
shell_out!("#{new_resource.homebrew_path} uninstall --cask #{new_resource.cask_name}",
|
79
79
|
user: new_resource.owner,
|
80
80
|
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
|
81
81
|
cwd: ::Dir.home(new_resource.owner))
|
@@ -93,7 +93,7 @@ class Chef
|
|
93
93
|
# @return [Boolean]
|
94
94
|
def casked?
|
95
95
|
unscoped_name = new_resource.cask_name.split("/").last
|
96
|
-
shell_out!("#{new_resource.homebrew_path} cask
|
96
|
+
shell_out!("#{new_resource.homebrew_path} list --cask 2>/dev/null",
|
97
97
|
user: new_resource.owner,
|
98
98
|
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
|
99
99
|
cwd: ::Dir.home(new_resource.owner)).stdout.split.include?(unscoped_name)
|
@@ -131,18 +131,18 @@ class Chef
|
|
131
131
|
# darwin
|
132
132
|
declare_resource(:execute, "set HostName via scutil") do
|
133
133
|
command "/usr/sbin/scutil --set HostName #{new_resource.hostname}"
|
134
|
-
not_if { shell_out
|
134
|
+
not_if { shell_out("/usr/sbin/scutil --get HostName").stdout.chomp == new_resource.hostname }
|
135
135
|
notifies :reload, "ohai[reload hostname]"
|
136
136
|
end
|
137
137
|
declare_resource(:execute, "set ComputerName via scutil") do
|
138
138
|
command "/usr/sbin/scutil --set ComputerName #{new_resource.hostname}"
|
139
|
-
not_if { shell_out
|
139
|
+
not_if { shell_out("/usr/sbin/scutil --get ComputerName").stdout.chomp == new_resource.hostname }
|
140
140
|
notifies :reload, "ohai[reload hostname]"
|
141
141
|
end
|
142
142
|
shortname = new_resource.hostname[/[^\.]*/]
|
143
143
|
declare_resource(:execute, "set LocalHostName via scutil") do
|
144
144
|
command "/usr/sbin/scutil --set LocalHostName #{shortname}"
|
145
|
-
not_if { shell_out
|
145
|
+
not_if { shell_out("/usr/sbin/scutil --get LocalHostName").stdout.chomp == shortname }
|
146
146
|
notifies :reload, "ohai[reload hostname]"
|
147
147
|
end
|
148
148
|
when linux?
|