chef 17.0.242-universal-mingw32 → 17.4.25-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -14
- data/Rakefile +2 -2
- data/chef.gemspec +10 -20
- data/lib/chef/action_collection.rb +6 -26
- data/lib/chef/application/base.rb +15 -0
- data/lib/chef/application.rb +4 -2
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/client.rb +7 -1
- data/lib/chef/compliance/default_attributes.rb +5 -3
- data/lib/chef/compliance/reporter/automate.rb +1 -1
- data/lib/chef/compliance/runner.rb +17 -3
- data/lib/chef/cookbook/cookbook_version_loader.rb +3 -3
- data/lib/chef/cookbook/gem_installer.rb +5 -1
- data/lib/chef/cookbook_version.rb +26 -4
- data/lib/chef/data_collector/run_end_message.rb +1 -1
- data/lib/chef/data_collector.rb +0 -1
- data/lib/chef/deprecated.rb +14 -4
- data/lib/chef/dsl/declare_resource.rb +5 -10
- data/lib/chef/dsl/render_helpers.rb +44 -0
- data/lib/chef/dsl/secret.rb +64 -0
- data/lib/chef/dsl/toml.rb +116 -0
- data/lib/chef/dsl/universal.rb +5 -0
- data/lib/chef/dsl.rb +1 -0
- data/lib/chef/event_dispatch/base.rb +2 -1
- data/lib/chef/exceptions.rb +23 -0
- data/lib/chef/formatters/doc.rb +2 -1
- data/lib/chef/formatters/error_mapper.rb +2 -2
- data/lib/chef/handler/slow_report.rb +66 -0
- data/lib/chef/handler.rb +46 -8
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/node.rb +21 -20
- data/lib/chef/policy_builder/policyfile.rb +88 -45
- data/lib/chef/provider/directory.rb +6 -6
- data/lib/chef/provider/execute.rb +1 -1
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/launchd.rb +6 -6
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/lwrp_base.rb +1 -1
- data/lib/chef/provider/package/dnf/dnf_helper.py +11 -10
- data/lib/chef/provider/package/dnf/python_helper.rb +9 -8
- data/lib/chef/provider/package/habitat.rb +168 -0
- data/lib/chef/provider/package/powershell.rb +5 -0
- data/lib/chef/provider/package/yum/python_helper.rb +15 -10
- data/lib/chef/provider/package/yum/yum_helper.py +46 -62
- data/lib/chef/provider/package/yum.rb +1 -4
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/subversion.rb +4 -4
- data/lib/chef/provider/support/yum_repo.erb +1 -1
- data/lib/chef/provider/support/zypper_repo.erb +4 -2
- data/lib/chef/provider/systemd_unit.rb +18 -17
- data/lib/chef/provider/template/content.rb +1 -1
- data/lib/chef/provider/user/mac.rb +3 -3
- data/lib/chef/provider/windows_script.rb +1 -1
- data/lib/chef/provider/yum_repository.rb +27 -43
- data/lib/chef/provider/zypper_repository.rb +30 -34
- data/lib/chef/provider.rb +26 -1
- data/lib/chef/provider_resolver.rb +8 -2
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource/alternatives.rb +5 -5
- data/lib/chef/resource/apt_preference.rb +2 -2
- data/lib/chef/resource/apt_repository.rb +2 -2
- data/lib/chef/resource/apt_update.rb +4 -4
- data/lib/chef/resource/build_essential.rb +1 -1
- data/lib/chef/resource/chef_client_config.rb +10 -5
- data/lib/chef/resource/chef_client_cron.rb +3 -3
- data/lib/chef/resource/chef_client_launchd.rb +3 -3
- data/lib/chef/resource/chef_client_scheduled_task.rb +15 -15
- data/lib/chef/resource/chef_client_systemd_timer.rb +3 -3
- data/lib/chef/resource/chef_client_trusted_certificate.rb +2 -2
- data/lib/chef/resource/chef_handler.rb +2 -2
- data/lib/chef/resource/chef_sleep.rb +1 -1
- data/lib/chef/resource/chef_vault_secret.rb +2 -2
- data/lib/chef/resource/chocolatey_feature.rb +2 -2
- data/lib/chef/resource/chocolatey_source.rb +1 -1
- data/lib/chef/resource/cron/cron_d.rb +4 -6
- data/lib/chef/resource/cron_access.rb +1 -1
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dsc_resource.rb +1 -1
- data/lib/chef/resource/execute.rb +5 -5
- data/lib/chef/resource/gem_package.rb +2 -1
- data/lib/chef/resource/group.rb +4 -4
- data/lib/chef/resource/habitat/_habitat_shared.rb +28 -0
- data/lib/chef/resource/habitat/habitat_package.rb +129 -0
- data/lib/chef/resource/habitat/habitat_sup.rb +329 -0
- data/lib/chef/resource/habitat/habitat_sup_systemd.rb +67 -0
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +90 -0
- data/lib/chef/resource/habitat_config.rb +107 -0
- data/lib/chef/resource/habitat_install.rb +247 -0
- data/lib/chef/resource/habitat_service.rb +451 -0
- data/lib/chef/resource/habitat_user_toml.rb +92 -0
- data/lib/chef/resource/homebrew_cask.rb +18 -7
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +4 -3
- data/lib/chef/resource/homebrew_update.rb +2 -2
- data/lib/chef/resource/hostname.rb +49 -7
- data/lib/chef/resource/inspec_waiver_file_entry.rb +156 -0
- data/lib/chef/resource/kernel_module.rb +6 -6
- data/lib/chef/resource/launchd.rb +3 -3
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/lwrp_base.rb +18 -3
- data/lib/chef/resource/macos_userdefaults.rb +2 -2
- data/lib/chef/resource/ohai_hint.rb +2 -6
- data/lib/chef/resource/openbsd_package.rb +17 -0
- data/lib/chef/resource/openssl_dhparam.rb +1 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +1 -3
- data/lib/chef/resource/openssl_ec_public_key.rb +1 -3
- data/lib/chef/resource/openssl_rsa_private_key.rb +1 -3
- data/lib/chef/resource/openssl_rsa_public_key.rb +1 -3
- data/lib/chef/resource/openssl_x509_certificate.rb +1 -4
- data/lib/chef/resource/openssl_x509_crl.rb +1 -3
- data/lib/chef/resource/openssl_x509_request.rb +1 -3
- data/lib/chef/resource/osx_profile.rb +3 -3
- data/lib/chef/resource/plist.rb +1 -1
- data/lib/chef/resource/powershell_package_source.rb +2 -4
- data/lib/chef/resource/reboot.rb +38 -9
- data/lib/chef/resource/remote_directory.rb +2 -2
- data/lib/chef/resource/remote_file.rb +3 -3
- data/lib/chef/resource/rhsm_errata.rb +0 -2
- data/lib/chef/resource/rhsm_errata_level.rb +1 -5
- data/lib/chef/resource/rhsm_repo.rb +15 -0
- data/lib/chef/resource/rhsm_subscription.rb +5 -5
- data/lib/chef/resource/ruby_block.rb +100 -0
- data/lib/chef/resource/scm/subversion.rb +1 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +4 -7
- data/lib/chef/resource/sudo.rb +2 -6
- data/lib/chef/resource/support/HabService.dll.config.erb +19 -0
- data/lib/chef/resource/support/client.erb +8 -1
- data/lib/chef/resource/support/sup.toml.erb +179 -0
- data/lib/chef/resource/swap_file.rb +2 -6
- data/lib/chef/resource/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +3 -3
- data/lib/chef/resource/timezone.rb +1 -1
- data/lib/chef/resource/user_ulimit.rb +2 -2
- data/lib/chef/resource/windows_ad_join.rb +2 -2
- data/lib/chef/resource/windows_audit_policy.rb +2 -2
- data/lib/chef/resource/windows_auto_run.rb +2 -2
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_defender.rb +163 -0
- data/lib/chef/resource/windows_defender_exclusion.rb +125 -0
- data/lib/chef/resource/windows_dfs_folder.rb +2 -2
- data/lib/chef/resource/windows_dfs_namespace.rb +2 -2
- data/lib/chef/resource/windows_dns_record.rb +2 -2
- data/lib/chef/resource/windows_dns_zone.rb +2 -2
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +3 -3
- data/lib/chef/resource/windows_feature_dism.rb +3 -5
- data/lib/chef/resource/windows_feature_powershell.rb +3 -3
- data/lib/chef/resource/windows_firewall_profile.rb +2 -2
- data/lib/chef/resource/windows_firewall_rule.rb +20 -6
- data/lib/chef/resource/windows_font.rb +2 -2
- data/lib/chef/resource/windows_pagefile.rb +104 -65
- data/lib/chef/resource/windows_path.rb +4 -4
- data/lib/chef/resource/windows_printer.rb +80 -61
- data/lib/chef/resource/windows_printer_port.rb +48 -65
- data/lib/chef/resource/windows_security_policy.rb +7 -4
- data/lib/chef/resource/windows_share.rb +2 -2
- data/lib/chef/resource/windows_shortcut.rb +1 -1
- data/lib/chef/resource/windows_task.rb +2 -2
- data/lib/chef/resource/windows_uac.rb +3 -5
- data/lib/chef/resource/windows_update_settings.rb +259 -0
- data/lib/chef/resource/windows_user_privilege.rb +2 -2
- data/lib/chef/resource/windows_workgroup.rb +2 -2
- data/lib/chef/resource/yum_package.rb +11 -15
- data/lib/chef/resource/zypper_package.rb +4 -4
- data/lib/chef/resource/zypper_repository.rb +28 -8
- data/lib/chef/resource.rb +20 -25
- data/lib/chef/resource_builder.rb +8 -2
- data/lib/chef/resource_inspector.rb +6 -2
- data/lib/chef/resource_reporter.rb +0 -1
- data/lib/chef/resources.rb +13 -1
- data/lib/chef/run_lock.rb +1 -1
- data/lib/chef/runner.rb +1 -1
- data/lib/chef/secret_fetcher/aws_secrets_manager.rb +65 -0
- data/lib/chef/secret_fetcher/azure_key_vault.rb +78 -0
- data/lib/chef/secret_fetcher/base.rb +76 -0
- data/lib/chef/secret_fetcher/example.rb +46 -0
- data/lib/chef/secret_fetcher.rb +55 -0
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +9 -2
- data/spec/data/knife-home/.chef/plugins/knife/example_home_subcommand.rb +0 -0
- data/spec/data/knife-site-subcommands/plugins/knife/example_subcommand.rb +0 -0
- data/spec/data/knife_subcommand/test_explicit_category.rb +7 -0
- data/spec/data/knife_subcommand/test_name_mapping.rb +4 -0
- data/spec/data/knife_subcommand/test_yourself.rb +21 -0
- data/spec/functional/mixin/from_file_spec.rb +1 -1
- data/spec/functional/resource/dnf_package_spec.rb +857 -537
- data/spec/functional/resource/group_spec.rb +1 -1
- data/spec/functional/resource/link_spec.rb +1 -1
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/windows_env_spec.rb +2 -2
- data/spec/functional/resource/windows_hostname_spec.rb +91 -0
- data/spec/functional/resource/windows_pagefile_spec.rb +98 -0
- data/spec/functional/resource/yum_package_spec.rb +495 -428
- data/spec/integration/client/client_spec.rb +0 -20
- data/spec/integration/compliance/compliance_spec.rb +1 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
- data/spec/integration/recipes/resource_action_spec.rb +6 -6
- data/spec/integration/recipes/unified_mode_spec.rb +70 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/knife.rb +37 -0
- data/spec/support/shared/integration/knife_support.rb +192 -0
- data/spec/support/shared/unit/knife_shared.rb +39 -0
- data/spec/support/shared/unit/provider/file.rb +3 -9
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +1 -1
- data/spec/unit/compliance/runner_spec.rb +46 -2
- data/spec/unit/cookbook_version_spec.rb +52 -0
- data/spec/unit/data_collector_spec.rb +47 -1
- data/spec/unit/dsl/render_helpers_spec.rb +102 -0
- data/spec/unit/dsl/secret_spec.rb +71 -0
- data/spec/unit/handler_spec.rb +8 -2
- data/spec/unit/policy_builder/dynamic_spec.rb +0 -5
- data/spec/unit/policy_builder/policyfile_spec.rb +144 -56
- data/spec/unit/provider/apt_update_spec.rb +3 -1
- data/spec/unit/provider/link_spec.rb +1 -1
- data/spec/unit/provider/mount/aix_spec.rb +1 -1
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -0
- data/spec/unit/provider/package/powershell_spec.rb +74 -12
- data/spec/unit/provider/package/yum/python_helper_spec.rb +1 -0
- data/spec/unit/provider/service/systemd_service_spec.rb +2 -2
- data/spec/unit/provider/systemd_unit_spec.rb +2 -2
- data/spec/unit/provider/zypper_repository_spec.rb +3 -10
- data/spec/unit/provider_spec.rb +23 -0
- data/spec/unit/resource/homebrew_cask_spec.rb +29 -11
- data/spec/unit/resource/inspec_waiver_file_entry_spec.rb +80 -0
- data/spec/unit/resource/rhsm_subscription_spec.rb +50 -3
- data/spec/unit/resource/systemd_unit_spec.rb +1 -1
- data/spec/unit/resource/windows_defender_exclusion_spec.rb +62 -0
- data/spec/unit/resource/windows_defender_spec.rb +71 -0
- data/spec/unit/resource/windows_firewall_rule_spec.rb +12 -7
- data/spec/unit/resource/windows_pagefile_spec.rb +4 -9
- data/spec/unit/resource/windows_update_settings_spec.rb +64 -0
- data/spec/unit/resource/zypper_repository_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +19 -8
- data/spec/unit/secret_fetcher/aws_secrets_manager_spec.rb +70 -0
- data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +70 -0
- data/spec/unit/secret_fetcher_spec.rb +82 -0
- data/tasks/rspec.rb +4 -9
- metadata +65 -161
- data/lib/chef/provider/package/yum/simplejson/LICENSE.txt +0 -79
- data/lib/chef/provider/package/yum/simplejson/__init__.py +0 -318
- data/lib/chef/provider/package/yum/simplejson/__init__.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/decoder.py +0 -354
- data/lib/chef/provider/package/yum/simplejson/decoder.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/encoder.py +0 -440
- data/lib/chef/provider/package/yum/simplejson/encoder.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/scanner.py +0 -65
- data/lib/chef/provider/package/yum/simplejson/scanner.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/tool.py +0 -37
@@ -2,45 +2,26 @@
|
|
2
2
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
3
3
|
|
4
4
|
#
|
5
|
-
# NOTE: this actually needs to run under python2.
|
6
|
-
# please manually test changes on
|
5
|
+
# NOTE: this actually needs to run under python2.7 and centos 6.x through python3 and centos 7.x
|
6
|
+
# please manually test changes on centos6 boxes or you will almost certainly break things.
|
7
7
|
#
|
8
8
|
|
9
9
|
import sys
|
10
10
|
import yum
|
11
11
|
import signal
|
12
12
|
import os
|
13
|
-
|
14
|
-
|
15
|
-
except ImportError: import simplejson as json
|
13
|
+
import fcntl
|
14
|
+
import json
|
16
15
|
import re
|
17
16
|
from rpmUtils.miscutils import stringToVersion,compareEVR
|
18
17
|
from rpmUtils.arch import getBaseArch, getArchList
|
19
|
-
|
20
|
-
|
21
|
-
try: from yum.misc import string_to_prco_tuple
|
22
|
-
except ImportError:
|
23
|
-
# RHEL5 compat
|
24
|
-
def string_to_prco_tuple(prcoString):
|
25
|
-
prco_split = prcoString.split()
|
26
|
-
n, f, v = prco_split
|
27
|
-
(prco_e, prco_v, prco_r) = stringToVersion(v)
|
28
|
-
return (n, f, (prco_e, prco_v, prco_r))
|
18
|
+
from yum.misc import string_to_prco_tuple
|
29
19
|
|
30
20
|
# hack to work around https://github.com/chef/chef/issues/7126
|
31
21
|
# see https://bugzilla.redhat.com/show_bug.cgi?id=1396248
|
32
22
|
if not hasattr(yum.packages.FakeRepository, 'compare_providers_priority'):
|
33
23
|
yum.packages.FakeRepository.compare_providers_priority = 99
|
34
24
|
|
35
|
-
base = None
|
36
|
-
|
37
|
-
def get_base():
|
38
|
-
global base
|
39
|
-
if base is None:
|
40
|
-
base = yum.YumBase()
|
41
|
-
setup_exit_handler()
|
42
|
-
return base
|
43
|
-
|
44
25
|
def versioncompare(versions):
|
45
26
|
arch_list = getArchList()
|
46
27
|
candidate_arch1 = versions[0].split(".")[-1]
|
@@ -51,9 +32,9 @@ def versioncompare(versions):
|
|
51
32
|
# then we'll chop the arch component (assuming it *is* a valid one) from the first version string
|
52
33
|
# so we're only comparing the evr portions.
|
53
34
|
if (candidate_arch2 not in arch_list) and (candidate_arch1 in arch_list):
|
54
|
-
|
35
|
+
final_version1 = versions[0].replace("." + candidate_arch1,"")
|
55
36
|
else:
|
56
|
-
|
37
|
+
final_version1 = versions[0]
|
57
38
|
|
58
39
|
final_version2 = versions[1]
|
59
40
|
|
@@ -64,37 +45,24 @@ def versioncompare(versions):
|
|
64
45
|
outpipe.write("%(e)s\n" % { 'e': evr_comparison })
|
65
46
|
outpipe.flush()
|
66
47
|
|
67
|
-
def install_only_packages(name):
|
68
|
-
base = get_base()
|
48
|
+
def install_only_packages(base, name):
|
69
49
|
if name in base.conf.installonlypkgs:
|
70
|
-
|
50
|
+
outpipe.write('True\n')
|
71
51
|
else:
|
72
|
-
|
52
|
+
outpipe.write('False\n')
|
73
53
|
outpipe.flush()
|
74
54
|
|
75
|
-
|
76
|
-
try:
|
77
|
-
any
|
78
|
-
except NameError:
|
79
|
-
def any(s):
|
80
|
-
for v in s:
|
81
|
-
if v:
|
82
|
-
return True
|
83
|
-
return False
|
84
|
-
|
85
|
-
def query(command):
|
86
|
-
base = get_base()
|
87
|
-
|
55
|
+
def query(base, command):
|
88
56
|
enabled_repos = base.repos.listEnabled()
|
89
57
|
|
90
58
|
# Handle any repocontrols passed in with our options
|
91
59
|
|
92
60
|
if 'repos' in command:
|
93
|
-
|
94
|
-
|
95
|
-
|
61
|
+
for repo in command['repos']:
|
62
|
+
if 'enable' in repo:
|
63
|
+
base.repos.enableRepo(repo['enable'])
|
96
64
|
if 'disable' in repo:
|
97
|
-
|
65
|
+
base.repos.disableRepo(repo['disable'])
|
98
66
|
|
99
67
|
args = { 'name': command['provides'] }
|
100
68
|
do_nevra = False
|
@@ -136,7 +104,7 @@ def query(command):
|
|
136
104
|
# returnPackages and searchProvides and then apply the Nevra filters to those results.
|
137
105
|
pkgs = obj.searchNevra(**args)
|
138
106
|
if (command['action'] == "whatinstalled") and (not pkgs):
|
139
|
-
|
107
|
+
pkgs = obj.searchNevra(name=args['name'], arch=desired_arch)
|
140
108
|
else:
|
141
109
|
pats = [command['provides']]
|
142
110
|
pkgs = obj.returnPackages(patterns=pats)
|
@@ -157,13 +125,13 @@ def query(command):
|
|
157
125
|
|
158
126
|
# Reset any repos we were passed in enablerepo/disablerepo to the original state in enabled_repos
|
159
127
|
if 'repos' in command:
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
128
|
+
for repo in command['repos']:
|
129
|
+
if 'enable' in repo:
|
130
|
+
if base.repos.getRepo(repo['enable']) not in enabled_repos:
|
131
|
+
base.repos.disableRepo(repo['enable'])
|
164
132
|
if 'disable' in repo:
|
165
|
-
|
166
|
-
|
133
|
+
if base.repos.getRepo(repo['disable']) in enabled_repos:
|
134
|
+
base.repos.enableRepo(repo['disable'])
|
167
135
|
|
168
136
|
# the design of this helper is that it should try to be 'brittle' and fail hard and exit in order
|
169
137
|
# to keep process tables clean. additional error handling should probably be added to the retry loop
|
@@ -179,21 +147,29 @@ def setup_exit_handler():
|
|
179
147
|
signal.signal(signal.SIGPIPE, exit_handler)
|
180
148
|
signal.signal(signal.SIGQUIT, exit_handler)
|
181
149
|
|
150
|
+
def set_blocking(fd):
|
151
|
+
old_flags = fcntl.fcntl(fd, fcntl.F_GETFL)
|
152
|
+
fcntl.fcntl(fd, fcntl.F_SETFL, old_flags & ~os.O_NONBLOCK)
|
153
|
+
|
154
|
+
base = None
|
155
|
+
|
182
156
|
if len(sys.argv) < 3:
|
183
|
-
|
184
|
-
|
157
|
+
inpipe = sys.stdin
|
158
|
+
outpipe = sys.stdout
|
185
159
|
else:
|
186
|
-
|
187
|
-
|
160
|
+
set_blocking(int(sys.argv[1]))
|
161
|
+
set_blocking(int(sys.argv[2]))
|
162
|
+
inpipe = os.fdopen(int(sys.argv[1]), "r")
|
163
|
+
outpipe = os.fdopen(int(sys.argv[2]), "w")
|
188
164
|
|
189
165
|
try:
|
166
|
+
setup_exit_handler()
|
190
167
|
while 1:
|
191
168
|
# stop the process if the parent proc goes away
|
192
169
|
ppid = os.getppid()
|
193
170
|
if ppid == 1:
|
194
171
|
raise RuntimeError("orphaned")
|
195
172
|
|
196
|
-
setup_exit_handler()
|
197
173
|
line = inpipe.readline()
|
198
174
|
|
199
175
|
# only way to detect EOF in python
|
@@ -205,14 +181,22 @@ try:
|
|
205
181
|
except ValueError, e:
|
206
182
|
raise RuntimeError("bad json parse")
|
207
183
|
|
184
|
+
if base is None:
|
185
|
+
base = yum.YumBase()
|
186
|
+
|
208
187
|
if command['action'] == "whatinstalled":
|
209
|
-
query(command)
|
188
|
+
query(base, command)
|
210
189
|
elif command['action'] == "whatavailable":
|
211
|
-
query(command)
|
190
|
+
query(base, command)
|
212
191
|
elif command['action'] == "versioncompare":
|
213
192
|
versioncompare(command['versions'])
|
214
193
|
elif command['action'] == "installonlypkgs":
|
215
|
-
|
194
|
+
install_only_packages(base, command['package'])
|
195
|
+
elif command['action'] == "close_rpmdb":
|
196
|
+
base.closeRpmDB()
|
197
|
+
base = None
|
198
|
+
outpipe.write('nil nil nil\n')
|
199
|
+
outpipe.flush()
|
216
200
|
else:
|
217
201
|
raise RuntimeError("bad command")
|
218
202
|
finally:
|
@@ -237,11 +237,8 @@ class Chef
|
|
237
237
|
@installed_version[index]
|
238
238
|
end
|
239
239
|
|
240
|
-
# cache flushing is accomplished by simply restarting the python helper. this produces a roughly
|
241
|
-
# 15% hit to the runtime of installing/removing/upgrading packages. correctly using multipackage
|
242
|
-
# array installs (and the multipackage cookbook) can produce 600% improvements in runtime.
|
243
240
|
def flushcache
|
244
|
-
python_helper.
|
241
|
+
python_helper.close_rpmdb
|
245
242
|
end
|
246
243
|
|
247
244
|
def yum_binary
|
@@ -78,7 +78,7 @@ class Chef
|
|
78
78
|
def define_resource_requirements
|
79
79
|
requirements.assert(:create, :create_if_missing, :delete, :delete_key) do |a|
|
80
80
|
a.assertion { registry.hive_exists?(new_resource.key) }
|
81
|
-
a.failure_message(Chef::Exceptions::Win32RegHiveMissing, "Hive #{new_resource.key.split(
|
81
|
+
a.failure_message(Chef::Exceptions::Win32RegHiveMissing, "Hive #{new_resource.key.split("\\").shift} does not exist")
|
82
82
|
end
|
83
83
|
|
84
84
|
requirements.assert(:create) do |a|
|
@@ -80,7 +80,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
80
80
|
@systemd_service_status ||= begin
|
81
81
|
# Collect all the status information for a service and returns it at once
|
82
82
|
options, args = get_systemctl_options_args
|
83
|
-
s = shell_out!(systemctl_path, args, "show", "-p", "UnitFileState", "-p", "ActiveState", new_resource.service_name, options)
|
83
|
+
s = shell_out!(systemctl_path, args, "show", "-p", "UnitFileState", "-p", "ActiveState", new_resource.service_name, **options)
|
84
84
|
# e.g. /bin/systemctl --system show -p UnitFileState -p ActiveState sshd.service
|
85
85
|
# Returns something like:
|
86
86
|
# ActiveState=active
|
@@ -55,7 +55,7 @@ class Chef
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
action :checkout do
|
58
|
+
action :checkout, description: "Clone or check out the source. When a checkout is available, this provider does nothing." do
|
59
59
|
if target_dir_non_existent_or_empty?
|
60
60
|
converge_by("perform checkout of #{new_resource.repository} into #{new_resource.destination}") do
|
61
61
|
shell_out!(checkout_command, run_options)
|
@@ -65,7 +65,7 @@ class Chef
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
action :export do
|
68
|
+
action :export, description: "Export the source, excluding or removing any version control artifacts." do
|
69
69
|
if target_dir_non_existent_or_empty?
|
70
70
|
action_force_export
|
71
71
|
else
|
@@ -73,13 +73,13 @@ class Chef
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
action :force_export do
|
76
|
+
action :force_export, description: "Export the source, excluding or removing any version control artifacts and force an export of the source that is overwriting the existing copy (if it exists)." do
|
77
77
|
converge_by("export #{new_resource.repository} into #{new_resource.destination}") do
|
78
78
|
shell_out!(export_command, run_options)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
action :sync do
|
82
|
+
action :sync, description: "Update the source to the specified version, or get a new clone or checkout. This action causes a hard reset of the index and working tree, discarding any uncommitted changes." do
|
83
83
|
assert_target_directory_valid!
|
84
84
|
if ::File.exist?(::File.join(new_resource.destination, ".svn"))
|
85
85
|
current_rev = find_current_revision
|
@@ -1,15 +1,17 @@
|
|
1
|
-
# This file was generated by Chef
|
1
|
+
# This file was generated by Chef Infra
|
2
2
|
# Do NOT modify this file by hand.
|
3
3
|
|
4
4
|
[<%= @config.repo_name %>]
|
5
5
|
<% %w{ type enabled autorefresh gpgcheck gpgkey baseurl mirrorlist path priority keeppackages mode refresh_cache }.each do |prop| -%>
|
6
|
-
<% next if @config.send(prop.to_sym).nil? -%>
|
6
|
+
<% next if @config.send(prop.to_sym).nil? || (@config.send(prop.to_sym).is_a?(Array) && @config.send(prop.to_sym).empty?) -%>
|
7
7
|
<%= prop %>=<%=
|
8
8
|
case @config.send(prop.to_sym)
|
9
9
|
when TrueClass
|
10
10
|
'1'
|
11
11
|
when FalseClass
|
12
12
|
'0'
|
13
|
+
when Array
|
14
|
+
@config.send(prop.to_sym).join("\n ")
|
13
15
|
else
|
14
16
|
@config.send(prop.to_sym)
|
15
17
|
end %>
|
@@ -22,6 +22,7 @@ require_relative "../resource/file"
|
|
22
22
|
require_relative "../resource/file/verification/systemd_unit"
|
23
23
|
require "iniparse"
|
24
24
|
require "shellwords" unless defined?(Shellwords)
|
25
|
+
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
25
26
|
|
26
27
|
class Chef
|
27
28
|
class Provider
|
@@ -60,7 +61,7 @@ class Chef
|
|
60
61
|
# Collect all the status information for a unit and return it at once
|
61
62
|
# This may fail if we are managing a template unit (e.g. with '@'), in which case
|
62
63
|
# we just ignore the error because unit status is irrelevant in that case
|
63
|
-
s = shell_out(*systemctl_cmd, "show", "-p", "UnitFileState", "-p", "ActiveState", new_resource.unit_name, systemctl_opts)
|
64
|
+
s = shell_out(*systemctl_cmd, "show", "-p", "UnitFileState", "-p", "ActiveState", new_resource.unit_name, **systemctl_opts)
|
64
65
|
# e.g. /bin/systemctl --system show -p UnitFileState -p ActiveState syslog.socket
|
65
66
|
# Returns something like:
|
66
67
|
# ActiveState=inactive
|
@@ -75,7 +76,7 @@ class Chef
|
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
78
|
-
action :create do
|
79
|
+
action :create, description: "Create a systemd unit file, if it does not already exist." do
|
79
80
|
if current_resource.content != new_resource.to_ini
|
80
81
|
converge_by("creating unit: #{new_resource.unit_name}") do
|
81
82
|
manage_unit_file(:create)
|
@@ -84,7 +85,7 @@ class Chef
|
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
|
-
action :delete do
|
88
|
+
action :delete, description: "Delete a systemd unit file, if it exists." do
|
88
89
|
if ::File.exist?(unit_path)
|
89
90
|
converge_by("deleting unit: #{new_resource.unit_name}") do
|
90
91
|
manage_unit_file(:delete)
|
@@ -93,19 +94,19 @@ class Chef
|
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
96
|
-
action :preset do
|
97
|
+
action :preset, description: "Restore the preset '`enable`/`disable`' configuration for a systemd unit. *New in #{ChefUtils::Dist::Infra::PRODUCT} 14.0.*" do
|
97
98
|
converge_by("restoring enable/disable preset configuration for unit: #{new_resource.unit_name}") do
|
98
99
|
systemctl_execute!(:preset, new_resource.unit_name)
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
102
|
-
action :revert do
|
103
|
+
action :revert, description: "Revert to a vendor's version of a systemd unit file. *New in #{ChefUtils::Dist::Infra::PRODUCT} 14.0.*" do
|
103
104
|
converge_by("reverting to vendor version of unit: #{new_resource.unit_name}") do
|
104
105
|
systemctl_execute!(:revert, new_resource.unit_name)
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
108
|
-
action :enable do
|
109
|
+
action :enable, description: "Ensure the unit will be started after the next system boot." do
|
109
110
|
if current_resource.static
|
110
111
|
logger.debug("#{new_resource.unit_name} is a static unit, enabling is a NOP.")
|
111
112
|
end
|
@@ -121,7 +122,7 @@ class Chef
|
|
121
122
|
end
|
122
123
|
end
|
123
124
|
|
124
|
-
action :disable do
|
125
|
+
action :disable, description: "Ensure the unit will not be started after the next system boot." do
|
125
126
|
if current_resource.static
|
126
127
|
logger.debug("#{new_resource.unit_name} is a static unit, disabling is a NOP.")
|
127
128
|
end
|
@@ -138,14 +139,14 @@ class Chef
|
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
141
|
-
action :reenable do
|
142
|
+
action :reenable, description: "Reenable a unit file. *New in #{ChefUtils::Dist::Infra::PRODUCT} 14.0.*" do
|
142
143
|
converge_by("reenabling unit: #{new_resource.unit_name}") do
|
143
144
|
systemctl_execute!(:reenable, new_resource.unit_name)
|
144
145
|
logger.info("#{new_resource} reenabled")
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
148
|
-
action :mask do
|
149
|
+
action :mask, description: "Ensure the unit will not start, even to satisfy dependencies." do
|
149
150
|
unless current_resource.masked
|
150
151
|
converge_by("masking unit: #{new_resource.unit_name}") do
|
151
152
|
systemctl_execute!(:mask, new_resource.unit_name)
|
@@ -154,7 +155,7 @@ class Chef
|
|
154
155
|
end
|
155
156
|
end
|
156
157
|
|
157
|
-
action :unmask do
|
158
|
+
action :unmask, description: "Stop the unit from being masked and cause it to start as specified." do
|
158
159
|
if current_resource.masked
|
159
160
|
converge_by("unmasking unit: #{new_resource.unit_name}") do
|
160
161
|
systemctl_execute!(:unmask, new_resource.unit_name)
|
@@ -163,7 +164,7 @@ class Chef
|
|
163
164
|
end
|
164
165
|
end
|
165
166
|
|
166
|
-
action :start do
|
167
|
+
action :start, description: "Start a systemd unit." do
|
167
168
|
unless current_resource.active
|
168
169
|
converge_by("starting unit: #{new_resource.unit_name}") do
|
169
170
|
systemctl_execute!(:start, new_resource.unit_name, default_env: false)
|
@@ -172,7 +173,7 @@ class Chef
|
|
172
173
|
end
|
173
174
|
end
|
174
175
|
|
175
|
-
action :stop do
|
176
|
+
action :stop, description: "Stop a running systemd unit." do
|
176
177
|
if current_resource.active
|
177
178
|
converge_by("stopping unit: #{new_resource.unit_name}") do
|
178
179
|
systemctl_execute!(:stop, new_resource.unit_name, default_env: false)
|
@@ -181,14 +182,14 @@ class Chef
|
|
181
182
|
end
|
182
183
|
end
|
183
184
|
|
184
|
-
action :restart do
|
185
|
+
action :restart, description: "Restart a systemd unit." do
|
185
186
|
converge_by("restarting unit: #{new_resource.unit_name}") do
|
186
187
|
systemctl_execute!(:restart, new_resource.unit_name, default_env: false)
|
187
188
|
logger.info("#{new_resource} restarted")
|
188
189
|
end
|
189
190
|
end
|
190
191
|
|
191
|
-
action :reload do
|
192
|
+
action :reload, description: "Reload the configuration file for a systemd unit." do
|
192
193
|
if current_resource.active
|
193
194
|
converge_by("reloading unit: #{new_resource.unit_name}") do
|
194
195
|
systemctl_execute!(:reload, new_resource.unit_name, default_env: false)
|
@@ -199,21 +200,21 @@ class Chef
|
|
199
200
|
end
|
200
201
|
end
|
201
202
|
|
202
|
-
action :try_restart do
|
203
|
+
action :try_restart, description: "Try to restart a systemd unit if the unit is running." do
|
203
204
|
converge_by("try-restarting unit: #{new_resource.unit_name}") do
|
204
205
|
systemctl_execute!("try-restart", new_resource.unit_name, default_env: false)
|
205
206
|
logger.info("#{new_resource} try-restarted")
|
206
207
|
end
|
207
208
|
end
|
208
209
|
|
209
|
-
action :reload_or_restart do
|
210
|
+
action :reload_or_restart, description: "For systemd units that are services, this action reloads the configuration of the service without restarting, if possible; otherwise, it will restart the service so the new configuration is applied." do
|
210
211
|
converge_by("reload-or-restarting unit: #{new_resource.unit_name}") do
|
211
212
|
systemctl_execute!("reload-or-restart", new_resource.unit_name, default_env: false)
|
212
213
|
logger.info("#{new_resource} reload-or-restarted")
|
213
214
|
end
|
214
215
|
end
|
215
216
|
|
216
|
-
action :reload_or_try_restart do
|
217
|
+
action :reload_or_try_restart, description: "For systemd units that are services, this action reloads the configuration of the service without restarting, if possible; otherwise, it will try to restart the service so the new configuration is applied." do
|
217
218
|
converge_by("reload-or-try-restarting unit: #{new_resource.unit_name}") do
|
218
219
|
systemctl_execute!("reload-or-try-restart", new_resource.unit_name, default_env: false)
|
219
220
|
logger.info("#{new_resource} reload-or-try-restarted")
|
@@ -63,7 +63,7 @@ class Chef
|
|
63
63
|
context[:template_finder] = template_finder
|
64
64
|
|
65
65
|
# helper variables
|
66
|
-
context[:cookbook_name] = new_resource.cookbook_name unless context.keys.include?(:
|
66
|
+
context[:cookbook_name] = new_resource.cookbook_name unless context.keys.include?(:cookbook_name)
|
67
67
|
context[:recipe_name] = new_resource.recipe_name unless context.keys.include?(:recipe_name)
|
68
68
|
context[:recipe_line_string] = new_resource.source_line unless context.keys.include?(:recipe_line_string)
|
69
69
|
context[:recipe_path] = new_resource.source_line_file unless context.keys.include?(:recipe_path)
|