chef 17.2.29-universal-mingw32 → 17.5.22-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 +6 -5
- data/chef.gemspec +3 -0
- data/lib/chef/application/base.rb +11 -1
- data/lib/chef/application.rb +3 -1
- data/lib/chef/client.rb +2 -3
- data/lib/chef/compliance/default_attributes.rb +5 -3
- data/lib/chef/compliance/input.rb +115 -0
- data/lib/chef/compliance/input_collection.rb +139 -0
- data/lib/chef/compliance/profile.rb +122 -0
- data/lib/chef/compliance/profile_collection.rb +109 -0
- data/lib/chef/compliance/reporter/automate.rb +1 -1
- data/lib/chef/compliance/runner.rb +62 -6
- data/lib/chef/compliance/waiver.rb +115 -0
- data/lib/chef/compliance/waiver_collection.rb +143 -0
- data/lib/chef/data_bag.rb +1 -2
- data/lib/chef/data_bag_item.rb +1 -2
- data/lib/chef/deprecated.rb +10 -4
- data/lib/chef/dsl/compliance.rb +38 -0
- data/lib/chef/dsl/reader_helpers.rb +51 -0
- data/lib/chef/dsl/recipe.rb +4 -2
- data/lib/chef/dsl/render_helpers.rb +44 -0
- data/lib/chef/dsl/secret.rb +62 -0
- data/lib/chef/dsl/toml.rb +116 -0
- data/lib/chef/dsl/universal.rb +7 -0
- data/lib/chef/dsl.rb +1 -0
- data/lib/chef/event_dispatch/base.rb +44 -2
- data/lib/chef/exceptions.rb +20 -0
- data/lib/chef/formatters/doc.rb +60 -13
- data/lib/chef/formatters/error_mapper.rb +2 -2
- data/lib/chef/formatters/minimal.rb +6 -5
- data/lib/chef/handler/slow_report.rb +1 -1
- data/lib/chef/http/basic_client.rb +15 -7
- data/lib/chef/http.rb +12 -8
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +88 -45
- data/lib/chef/provider/execute.rb +1 -1
- data/lib/chef/provider/file.rb +4 -2
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/launchd.rb +6 -6
- data/lib/chef/provider/link.rb +2 -2
- data/lib/chef/provider/lwrp_base.rb +1 -1
- data/lib/chef/provider/package/habitat.rb +168 -0
- data/lib/chef/provider/package/powershell.rb +5 -0
- data/lib/chef/provider/registry_key.rb +3 -2
- data/lib/chef/provider/remote_file/http.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/systemd_unit.rb +17 -16
- data/lib/chef/provider/template.rb +1 -1
- data/lib/chef/provider/user/mac.rb +3 -3
- data/lib/chef/provider/yum_repository.rb +27 -43
- data/lib/chef/provider/zypper_repository.rb +3 -3
- 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/archive_file.rb +17 -14
- data/lib/chef/resource/chef_client_config.rb +7 -2
- data/lib/chef/resource/chef_client_cron.rb +1 -1
- data/lib/chef/resource/chef_client_launchd.rb +1 -1
- data/lib/chef/resource/chef_client_scheduled_task.rb +46 -3
- data/lib/chef/resource/chef_client_systemd_timer.rb +1 -1
- data/lib/chef/resource/chef_client_trusted_certificate.rb +2 -2
- data/lib/chef/resource/chef_vault_secret.rb +2 -2
- data/lib/chef/resource/chocolatey_config.rb +13 -13
- data/lib/chef/resource/dsc_resource.rb +1 -1
- data/lib/chef/resource/execute.rb +5 -5
- data/lib/chef/resource/file/verification/json.rb +50 -0
- data/lib/chef/resource/file/verification/yaml.rb +52 -0
- data/lib/chef/resource/gem_package.rb +2 -1
- 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 +1 -1
- data/lib/chef/resource/inspec_input.rb +128 -0
- data/lib/chef/resource/inspec_waiver.rb +185 -0
- data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -2
- data/lib/chef/resource/launchd.rb +3 -3
- data/lib/chef/resource/lwrp_base.rb +1 -1
- data/lib/chef/resource/mount.rb +1 -1
- data/lib/chef/resource/registry_key.rb +36 -48
- data/lib/chef/resource/remote_file.rb +99 -3
- 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/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/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +3 -3
- data/lib/chef/resource/timezone.rb +2 -2
- data/lib/chef/resource/user_ulimit.rb +1 -0
- data/lib/chef/resource/windows_defender.rb +163 -0
- data/lib/chef/resource/windows_defender_exclusion.rb +125 -0
- data/lib/chef/resource/windows_printer.rb +78 -44
- data/lib/chef/resource/windows_printer_port.rb +1 -1
- data/lib/chef/resource/windows_uac.rb +3 -1
- data/lib/chef/resource/windows_update_settings.rb +259 -0
- data/lib/chef/resource/windows_user_privilege.rb +1 -1
- data/lib/chef/resource/yum_package.rb +1 -5
- data/lib/chef/resource.rb +13 -17
- data/lib/chef/resource_inspector.rb +6 -2
- data/lib/chef/resources.rb +14 -1
- data/lib/chef/run_context/cookbook_compiler.rb +112 -28
- data/lib/chef/run_context.rb +31 -1
- data/lib/chef/secret_fetcher/akeyless_vault.rb +57 -0
- 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/hashi_vault.rb +100 -0
- data/lib/chef/secret_fetcher.rb +61 -0
- data/lib/chef/version.rb +1 -1
- data/spec/data/archive_file/test_archive.tar.gz +0 -0
- data/spec/functional/mixin/from_file_spec.rb +1 -1
- data/spec/functional/resource/archive_file_spec.rb +87 -0
- data/spec/functional/resource/group_spec.rb +5 -1
- data/spec/functional/resource/link_spec.rb +8 -0
- data/spec/integration/compliance/compliance_spec.rb +61 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
- data/spec/integration/recipes/resource_action_spec.rb +6 -6
- data/spec/spec_helper.rb +3 -0
- data/spec/support/platform_helpers.rb +4 -0
- data/spec/support/ruby_installer.rb +51 -0
- data/spec/support/shared/unit/provider/file.rb +2 -8
- data/spec/unit/compliance/input_spec.rb +104 -0
- data/spec/unit/compliance/profile_spec.rb +120 -0
- data/spec/unit/compliance/runner_spec.rb +46 -2
- data/spec/unit/compliance/waiver_spec.rb +104 -0
- data/spec/unit/data_bag_item_spec.rb +2 -2
- data/spec/unit/data_bag_spec.rb +1 -1
- data/spec/unit/dsl/render_helpers_spec.rb +102 -0
- data/spec/unit/dsl/secret_spec.rb +71 -0
- data/spec/unit/formatters/doc_spec.rb +1 -1
- data/spec/unit/http/basic_client_spec.rb +30 -0
- data/spec/unit/http_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 +13 -7
- data/spec/unit/provider/mount/aix_spec.rb +1 -1
- data/spec/unit/provider/package/powershell_spec.rb +74 -12
- data/spec/unit/provider/remote_file/http_spec.rb +10 -0
- data/spec/unit/provider/template_spec.rb +2 -2
- data/spec/unit/provider_spec.rb +23 -0
- data/spec/unit/resource/archive_file_spec.rb +414 -3
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +69 -0
- data/spec/unit/resource/file/verification/json_spec.rb +72 -0
- data/spec/unit/resource/file/verification/yaml_spec.rb +67 -0
- data/spec/unit/resource/homebrew_cask_spec.rb +29 -11
- data/spec/unit/resource/inspec_input_spec.rb +300 -0
- data/spec/unit/resource/inspec_waiver_spec.rb +312 -0
- data/spec/unit/resource/mount_spec.rb +10 -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/user_ulimit_spec.rb +14 -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_update_settings_spec.rb +64 -0
- data/spec/unit/resource_spec.rb +19 -8
- data/spec/unit/secret_fetcher/akeyless_vault_spec.rb +37 -0
- 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/hashi_vault_spec.rb +80 -0
- data/spec/unit/secret_fetcher_spec.rb +82 -0
- data/tasks/rspec.rb +2 -1
- metadata +106 -7
@@ -22,6 +22,10 @@ require_relative "../resource"
|
|
22
22
|
|
23
23
|
class Chef
|
24
24
|
class Resource
|
25
|
+
# @todo
|
26
|
+
# 1. Allow updating the printer properties
|
27
|
+
# 2. Fail with a warning if the port can't be found and create_port is false
|
28
|
+
# 3. Fail with helpful messaging if the printer driver can't be installed
|
25
29
|
class WindowsPrinter < Chef::Resource
|
26
30
|
unified_mode true
|
27
31
|
|
@@ -29,7 +33,7 @@ class Chef
|
|
29
33
|
|
30
34
|
provides(:windows_printer) { true }
|
31
35
|
|
32
|
-
description "Use the **windows_printer** resource to setup Windows printers.
|
36
|
+
description "Use the **windows_printer** resource to setup Windows printers. This resource will automatically install the driver specified in the `driver_name` property and will automatically create a printer port using either the `ipv4_address` property or the `port_name` property."
|
33
37
|
introduced "14.0"
|
34
38
|
examples <<~DOC
|
35
39
|
**Create a printer**:
|
@@ -50,6 +54,23 @@ class Chef
|
|
50
54
|
action :delete
|
51
55
|
end
|
52
56
|
```
|
57
|
+
|
58
|
+
**Create a printer port and a printer that uses that port (new in 17.3)**
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
windows_printer_port '10.4.64.39' do
|
62
|
+
port_name 'My awesome printer port'
|
63
|
+
snmp_enabled true
|
64
|
+
port_protocol 2
|
65
|
+
end
|
66
|
+
|
67
|
+
windows_printer 'HP LaserJet 5th Floor' do
|
68
|
+
driver_name 'HP LaserJet 4100 Series PCL6'
|
69
|
+
port_name 'My awesome printer port'
|
70
|
+
ipv4_address '10.4.64.38'
|
71
|
+
create_port false
|
72
|
+
end
|
73
|
+
```
|
53
74
|
DOC
|
54
75
|
|
55
76
|
property :device_id, String,
|
@@ -84,25 +105,74 @@ class Chef
|
|
84
105
|
proc { |v| v.match(Resolv::IPv4::Regex) },
|
85
106
|
}
|
86
107
|
|
87
|
-
|
108
|
+
property :create_port, [TrueClass, FalseClass],
|
109
|
+
description: "Create a printer port for the printer. Set this to false and specify the `port_name` property if using the `windows_printer_port` resource to create the port instead.",
|
110
|
+
introduced: "17.3",
|
111
|
+
default: true, desired_state: false
|
112
|
+
|
113
|
+
property :port_name, String,
|
114
|
+
description: "The port name.",
|
115
|
+
default: lazy { |x| "IP_#{x.ipv4_address}" },
|
116
|
+
introduced: "17.3",
|
117
|
+
default_description: "The resource block name or the ipv4_address prepended with IP_."
|
88
118
|
|
89
|
-
# @todo Set @current_resource printer properties from registry
|
90
119
|
load_current_value do |new_resource|
|
91
|
-
|
120
|
+
printer_data = powershell_exec(%Q{Get-WmiObject -Class Win32_Printer -Filter "Name='#{new_resource.device_id}'"}).result
|
121
|
+
|
122
|
+
if printer_data.empty?
|
123
|
+
current_value_does_not_exist!
|
124
|
+
else
|
125
|
+
device_id new_resource.device_id
|
126
|
+
comment printer_data["Comment"]
|
127
|
+
default printer_data["Default"]
|
128
|
+
location printer_data["Location"]
|
129
|
+
shared printer_data["Shared"]
|
130
|
+
share_name printer_data["ShareName"]
|
131
|
+
port_name printer_data["PortName"]
|
132
|
+
|
133
|
+
driver_data = powershell_exec(%Q{Get-PrinterDriver -Name="#{new_resource.driver_name}"}).result
|
134
|
+
unless driver_data.empty?
|
135
|
+
driver_name new_resource.driver_name
|
136
|
+
end
|
137
|
+
end
|
92
138
|
end
|
93
139
|
|
94
140
|
action :create, description: "Create a new printer and printer port, if one doesn't already." do
|
95
|
-
if
|
141
|
+
if current_resource
|
96
142
|
Chef::Log.info "#{@new_resource} already exists - nothing to do."
|
97
143
|
else
|
98
|
-
|
99
|
-
|
144
|
+
# Create the printer port first unless the property is set to false
|
145
|
+
if new_resource.create_port
|
146
|
+
windows_printer_port new_resource.port_name do
|
147
|
+
ipv4_address new_resource.ipv4_address
|
148
|
+
port_name new_resource.port_name
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
converge_by("install driver #{new_resource.driver_name}") do
|
153
|
+
powershell_exec!("Add-PrinterDriver -Name '#{new_resource.driver_name}'")
|
154
|
+
end
|
155
|
+
|
156
|
+
converge_by("create #{@new_resource.device_id}") do
|
157
|
+
powershell_exec! <<-EOH
|
158
|
+
Set-WmiInstance -class Win32_Printer `
|
159
|
+
-EnableAllPrivileges `
|
160
|
+
-Argument @{ DeviceID = "#{new_resource.device_id}";
|
161
|
+
Comment = "#{new_resource.comment}";
|
162
|
+
Default = "$#{new_resource.default}";
|
163
|
+
DriverName = "#{new_resource.driver_name}";
|
164
|
+
Location = "#{new_resource.location}";
|
165
|
+
PortName = "#{new_resource.port_name}";
|
166
|
+
Shared = "$#{new_resource.shared}";
|
167
|
+
ShareName = "#{new_resource.share_name}";
|
168
|
+
}
|
169
|
+
EOH
|
100
170
|
end
|
101
171
|
end
|
102
172
|
end
|
103
173
|
|
104
174
|
action :delete, description: "Delete an existing printer. Note that this resource does not delete the associated printer port." do
|
105
|
-
if
|
175
|
+
if current_resource
|
106
176
|
converge_by("Delete #{new_resource.device_id}") do
|
107
177
|
powershell_exec!("Remove-Printer -Name '#{new_resource.device_id}'")
|
108
178
|
end
|
@@ -110,42 +180,6 @@ class Chef
|
|
110
180
|
Chef::Log.info "#{new_resource.device_id} doesn't exist - can't delete."
|
111
181
|
end
|
112
182
|
end
|
113
|
-
|
114
|
-
action_class do
|
115
|
-
# does the printer exist
|
116
|
-
#
|
117
|
-
# @param [String] name the name of the printer
|
118
|
-
# @return [Boolean]
|
119
|
-
def printer_exists?
|
120
|
-
printer_reg_key = PRINTERS_REG_KEY + new_resource.name
|
121
|
-
logger.trace "Checking to see if this reg key exists: '#{printer_reg_key}'"
|
122
|
-
registry_key_exists?(printer_reg_key)
|
123
|
-
end
|
124
|
-
|
125
|
-
# creates the printer port and then the printer
|
126
|
-
def create_printer
|
127
|
-
# Create the printer port first
|
128
|
-
windows_printer_port new_resource.ipv4_address
|
129
|
-
|
130
|
-
port_name = "IP_#{new_resource.ipv4_address}"
|
131
|
-
|
132
|
-
declare_resource(:powershell_script, "Creating printer: #{new_resource.device_id}") do
|
133
|
-
code <<-EOH
|
134
|
-
Set-WmiInstance -class Win32_Printer `
|
135
|
-
-EnableAllPrivileges `
|
136
|
-
-Argument @{ DeviceID = "#{new_resource.device_id}";
|
137
|
-
Comment = "#{new_resource.comment}";
|
138
|
-
Default = "$#{new_resource.default}";
|
139
|
-
DriverName = "#{new_resource.driver_name}";
|
140
|
-
Location = "#{new_resource.location}";
|
141
|
-
PortName = "#{port_name}";
|
142
|
-
Shared = "$#{new_resource.shared}";
|
143
|
-
ShareName = "#{new_resource.share_name}";
|
144
|
-
}
|
145
|
-
EOH
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
183
|
end
|
150
184
|
end
|
151
185
|
end
|
@@ -137,7 +137,7 @@ class Chef
|
|
137
137
|
|
138
138
|
action :delete, description: "Delete an existing printer port." do
|
139
139
|
if current_resource
|
140
|
-
converge_by("
|
140
|
+
converge_by("delete port #{new_resource.port_name}") do
|
141
141
|
powershell_exec!("Remove-PrinterPort -Name #{new_resource.port_name}")
|
142
142
|
end
|
143
143
|
else
|
@@ -104,7 +104,9 @@ class Chef
|
|
104
104
|
#
|
105
105
|
# @return [Integer]
|
106
106
|
def consent_behavior_users_symbol_to_reg(sym)
|
107
|
-
|
107
|
+
# Since 2 isn't a valid value for ConsentPromptBehaviorUser, assign the value at index as nil.
|
108
|
+
# https://docs.microsoft.com/en-us/windows/security/identity-protection/user-account-control/user-account-control-group-policy-and-registry-key-settings#registry-key-settings
|
109
|
+
[:auto_deny, :secure_prompt_for_creds, nil, :prompt_for_creds].index(sym)
|
108
110
|
end
|
109
111
|
end
|
110
112
|
end
|
@@ -0,0 +1,259 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sölvi Páll Ásgeirsson (<solvip@gmail.com>)
|
3
|
+
# Author:: Richard Lavey (richard.lavey@calastone.com)
|
4
|
+
# Author:: Tim Smith (tsmith@chef.io)
|
5
|
+
#
|
6
|
+
# Copyright:: 2014-2017, Sölvi Páll Ásgeirsson.
|
7
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
require_relative "../resource"
|
23
|
+
class Chef
|
24
|
+
class Resource
|
25
|
+
class WindowsUpdateSettings < Chef::Resource
|
26
|
+
unified_mode true
|
27
|
+
|
28
|
+
provides :windows_update_settings
|
29
|
+
|
30
|
+
description "Use the **windows_update_settings** resource to manage the various Windows Update patching options."
|
31
|
+
introduced "17.3"
|
32
|
+
examples <<~DOC
|
33
|
+
**Set Windows Update settings**:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
windows_update_settings 'Settings to Configure Windows Nodes to automatically receive updates' do
|
37
|
+
disable_os_upgrades true
|
38
|
+
elevate_non_admins true
|
39
|
+
block_windows_update_website true
|
40
|
+
automatically_install_minor_updates true
|
41
|
+
scheduled_install_day 'Friday'
|
42
|
+
scheduled_install_hour 18
|
43
|
+
update_other_ms_products true
|
44
|
+
action :enable
|
45
|
+
end
|
46
|
+
```
|
47
|
+
DOC
|
48
|
+
|
49
|
+
# required for the alias to pass validation
|
50
|
+
allowed_actions :set, :enable
|
51
|
+
|
52
|
+
DAYS = %W{Everyday Monday Tuesday Wednesday Thursday Friday Saturday Sunday}.freeze
|
53
|
+
UPDATE_OPTIONS = {
|
54
|
+
notify: 2,
|
55
|
+
download_and_notify: 3,
|
56
|
+
download_and_schedule: 4,
|
57
|
+
local_admin_decides: 5,
|
58
|
+
}.freeze
|
59
|
+
|
60
|
+
# HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate
|
61
|
+
|
62
|
+
property :disable_os_upgrades, [true, false], default: false, description: "Disable OS upgrades."
|
63
|
+
# options: 0 - let windows update update the os - false
|
64
|
+
# 1 - don't let windows update update the os - true
|
65
|
+
|
66
|
+
property :elevate_non_admins, [true, false], default: true, description: "Allow normal user accounts to temporarily be elevated to install patches."
|
67
|
+
# options: 0 - do not elevate a user to force an install - false
|
68
|
+
# 1 - do elevate the logged on user to install an update - true
|
69
|
+
|
70
|
+
property :add_to_target_wsus_group, [true, false], deprecated: "As of Chef Infra Client 17.3 the `add_to_target_wsus_group` property is no longer necessary."
|
71
|
+
# we set this registry value now automatically if the group name is set
|
72
|
+
|
73
|
+
property :target_wsus_group_name, String, description: "Add the node to a WSUS Target Group."
|
74
|
+
# options: --- a string representing the name of a target group you defined on your wsus server
|
75
|
+
|
76
|
+
property :wsus_server_url, String, description: "The URL of your WSUS server if you use one."
|
77
|
+
# options: --- a url for your internal update server in the form of https://my.updateserver.tld:4545 or whatever
|
78
|
+
|
79
|
+
property :wsus_status_server_url, String, deprecated: "As of Chef Infra Client 17.3 the `wsus_status_server_url` no longer needs to be set."
|
80
|
+
# this needs to be the same as wsus_server_url so we just set that value in both places now
|
81
|
+
|
82
|
+
# HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
|
83
|
+
|
84
|
+
property :block_windows_update_website, [true, false], default: false, description: "Block accessing the Windows Update website."
|
85
|
+
# options: 0 - allow access to the windows update website - false
|
86
|
+
# 1 - do not allow access to the windows update website - true
|
87
|
+
|
88
|
+
# HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU
|
89
|
+
|
90
|
+
property :automatic_update_option, [Integer, Symbol], equal_to: UPDATE_OPTIONS.keys, coerce: proc { |x| UPDATE_OPTIONS.key(x) || x },
|
91
|
+
default: :download_and_schedule,
|
92
|
+
description: "Control what to do when updates are found. This allows you to notify, automatically download and notify to install, automatically download and schedule the install, or let the local admin decide what action to take."
|
93
|
+
# options: 2 - notify before download
|
94
|
+
# 3 - auto download and notify
|
95
|
+
# 4 - auto download and schedule - must also set day and time (below)
|
96
|
+
# 5 - allow the local admin to decide
|
97
|
+
|
98
|
+
property :automatically_install_minor_updates, [true, false], default: false, description: "Automatically install minor updates."
|
99
|
+
# options: 0 - do not automatically install minor updates - false
|
100
|
+
# 1 - of course, silently install them! - true
|
101
|
+
|
102
|
+
property :enable_detection_frequency, [true, false], default: false, description: "Used to override the OS default of how often to check for updates"
|
103
|
+
# do i want my nodes checking for updates at a time interval i chose?
|
104
|
+
# options: 0 - do not enable the option for a custom interval - false
|
105
|
+
# 1 - yeah, buddy, i want to set my own interval for checking for updates - true
|
106
|
+
|
107
|
+
property :custom_detection_frequency, Integer, default: 22, description: "If you decided to override the OS default detection frequency, specify your choice here. Valid choices are 0 - 22",
|
108
|
+
callbacks: {
|
109
|
+
"should be a valid detection frequency (0-22)" => lambda { |p|
|
110
|
+
p >= 0 && p <= 22
|
111
|
+
},
|
112
|
+
}
|
113
|
+
# a time period of between 0 and 22 hours to check for new updates
|
114
|
+
# this is a hex value - convert it from dec to hex
|
115
|
+
|
116
|
+
property :no_reboot_with_users_logged_on, [true, false], default: true, description: "Prevents the OS from rebooting while someone is on the console."
|
117
|
+
# options: 0 - user is notified of pending reboot in xx minutes - false/off
|
118
|
+
# 1 - user is notified of pending reboot but can defer - true/on
|
119
|
+
|
120
|
+
property :disable_automatic_updates, [true, false], default: false, description: "Disable Windows Update."
|
121
|
+
# options: 0 - enable automatic updates to the local system - false
|
122
|
+
# 1 - disable automatic updates - true
|
123
|
+
|
124
|
+
property :scheduled_install_day, String, equal_to: DAYS, default: DAYS.first, description: "A day of the week to tell Windows when to install updates."
|
125
|
+
# options: Everyday - install every day
|
126
|
+
# Sunday - Saturday day of the week to install, 1 == sunday
|
127
|
+
|
128
|
+
property :scheduled_install_hour, Integer, description: "If you chose a scheduled day to install, then choose an hour on that day for you installation",
|
129
|
+
callbacks: {
|
130
|
+
"should be a valid hour in a 24 hour clock" => lambda { |p|
|
131
|
+
p > 0 && p < 25
|
132
|
+
},
|
133
|
+
}
|
134
|
+
# options: --- 2-digit number representing an hour of the day, uses a 24-hour clock, 12 == noon, 24 == midnight
|
135
|
+
|
136
|
+
property :update_other_ms_products, [true, false], default: true, description: "Allows for other Microsoft products to get updates too"
|
137
|
+
# options: 0 - do not allow wu to update other apps - remove key from hive - false/off
|
138
|
+
# 1 - please update all my stuff! - true/on
|
139
|
+
|
140
|
+
# \AU\AllowMUUpdateService dword: 1
|
141
|
+
|
142
|
+
property :custom_wsus_server, [true, false], deprecated: "As of Chef Infra Client 17.3 the `custom_wsus_server` no longer needs to be setup when specifying a WSUS endpoint."
|
143
|
+
# not necessary as we set this registry value automatically if a URL is set
|
144
|
+
|
145
|
+
action :set, description: "Set Windows Update settings." do
|
146
|
+
actual_day = convert_day(new_resource.scheduled_install_day)
|
147
|
+
|
148
|
+
registry_key 'HKEY_LOCAL_MACHINE\\Software\\Policies\\Microsoft\\Windows\\WindowsUpdate' do
|
149
|
+
recursive true
|
150
|
+
values [{
|
151
|
+
name: "DisableOSUpgrade",
|
152
|
+
type: :dword,
|
153
|
+
data: new_resource.disable_os_upgrades ? 1 : 0,
|
154
|
+
},
|
155
|
+
{
|
156
|
+
name: "ElevateNonAdmins",
|
157
|
+
type: :dword,
|
158
|
+
data: new_resource.elevate_non_admins ? 1 : 0,
|
159
|
+
},
|
160
|
+
{
|
161
|
+
name: "TargetGroupEnabled",
|
162
|
+
type: :dword,
|
163
|
+
data: new_resource.target_wsus_group_name ? 1 : 0,
|
164
|
+
},
|
165
|
+
{
|
166
|
+
name: "TargetGroup",
|
167
|
+
type: :string,
|
168
|
+
data: new_resource.target_wsus_group_name,
|
169
|
+
},
|
170
|
+
{
|
171
|
+
name: "WUServer",
|
172
|
+
type: :string,
|
173
|
+
data: new_resource.wsus_server_url,
|
174
|
+
},
|
175
|
+
{
|
176
|
+
name: "WUStatusServer",
|
177
|
+
type: :string,
|
178
|
+
data: new_resource.wsus_server_url, # status server and server need to be the same. Why? Ask Microsoft
|
179
|
+
}]
|
180
|
+
action :create
|
181
|
+
end
|
182
|
+
|
183
|
+
registry_key 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer' do
|
184
|
+
recursive true
|
185
|
+
values [{
|
186
|
+
name: "NoWindowsUpdate",
|
187
|
+
type: :dword,
|
188
|
+
data: new_resource.block_windows_update_website ? 1 : 0,
|
189
|
+
}]
|
190
|
+
action :create
|
191
|
+
end
|
192
|
+
|
193
|
+
registry_key 'HKEY_LOCAL_MACHINE\\Software\\Policies\\Microsoft\\Windows\\WindowsUpdate\\AU' do
|
194
|
+
recursive true
|
195
|
+
values [{
|
196
|
+
name: "AUOptions",
|
197
|
+
type: :dword,
|
198
|
+
data: UPDATE_OPTIONS[new_resource.automatic_update_option],
|
199
|
+
},
|
200
|
+
{
|
201
|
+
name: "AutoInstallMinorUpdates",
|
202
|
+
type: :dword,
|
203
|
+
data: new_resource.automatically_install_minor_updates ? 1 : 0,
|
204
|
+
},
|
205
|
+
{
|
206
|
+
name: "DetectionFrequencyEnabled",
|
207
|
+
type: :dword,
|
208
|
+
data: new_resource.enable_detection_frequency ? 1 : 0,
|
209
|
+
},
|
210
|
+
{
|
211
|
+
name: "DetectionFrequency",
|
212
|
+
type: :dword,
|
213
|
+
data: new_resource.custom_detection_frequency,
|
214
|
+
},
|
215
|
+
{
|
216
|
+
name: "NoAutoRebootWithLoggedOnUsers",
|
217
|
+
type: :dword,
|
218
|
+
data: new_resource.no_reboot_with_users_logged_on ? 1 : 0,
|
219
|
+
},
|
220
|
+
{
|
221
|
+
name: "NoAutoUpdate",
|
222
|
+
type: :dword,
|
223
|
+
data: new_resource.disable_automatic_updates ? 1 : 0,
|
224
|
+
},
|
225
|
+
{
|
226
|
+
name: "ScheduledInstallDay",
|
227
|
+
type: :dword,
|
228
|
+
data: actual_day,
|
229
|
+
},
|
230
|
+
{
|
231
|
+
name: "ScheduledInstallTime",
|
232
|
+
type: :dword,
|
233
|
+
data: new_resource.scheduled_install_hour,
|
234
|
+
},
|
235
|
+
{
|
236
|
+
name: "AllowMUUpdateService",
|
237
|
+
type: :dword,
|
238
|
+
data: new_resource.update_other_ms_products ? 1 : 0,
|
239
|
+
},
|
240
|
+
{
|
241
|
+
name: "UseWUServer",
|
242
|
+
type: :dword,
|
243
|
+
data: new_resource.wsus_server_url ? 1 : 0, # if we have a URL set then want to turn on WSUS functionality
|
244
|
+
}]
|
245
|
+
action :create
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
action_class do
|
250
|
+
def convert_day(day)
|
251
|
+
DAYS.index(day)
|
252
|
+
end
|
253
|
+
|
254
|
+
# support the old name as well
|
255
|
+
alias_method :action_enable, :action_set
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
@@ -139,7 +139,7 @@ class Chef
|
|
139
139
|
coerce: proc { |v| Array(v) },
|
140
140
|
callbacks: {
|
141
141
|
"Privilege property restricted to the following values: #{PRIVILEGE_OPTS}" => lambda { |n| (n - PRIVILEGE_OPTS).empty? },
|
142
|
-
}
|
142
|
+
}, identity: true
|
143
143
|
|
144
144
|
load_current_value do |new_resource|
|
145
145
|
if new_resource.principal && (new_resource.action.include?(:add) || new_resource.action.include?(:remove))
|
@@ -27,11 +27,7 @@ class Chef
|
|
27
27
|
provides :yum_package
|
28
28
|
provides :package, platform_family: "fedora_derived"
|
29
29
|
|
30
|
-
description "Use the **yum_package** resource to install, upgrade, and remove packages with Yum"
|
31
|
-
" for the Red Hat and CentOS platforms. The yum_package resource is able to resolve"\
|
32
|
-
" `provides` data for packages much like Yum can do when it is run from the command line."\
|
33
|
-
" This allows a variety of options for installing packages, like minimum versions,"\
|
34
|
-
" virtual provides, and library names."
|
30
|
+
description "Use the **yum_package** resource to install, upgrade, and remove packages with Yum for the Red Hat and CentOS platforms. The yum_package resource is able to resolve `provides` data for packages much like Yum can do when it is run from the command line. This allows a variety of options for installing packages, like minimum versions, virtual provides, and library names. Note: Support for using file names to install packages (as in `yum_package '/bin/sh'`) is not available because the volume of data required to parse for this is excessive."
|
35
31
|
examples <<~DOC
|
36
32
|
**Install an exact version**:
|
37
33
|
|
data/lib/chef/resource.rb
CHANGED
@@ -1063,7 +1063,8 @@ class Chef
|
|
1063
1063
|
# action for the resource.
|
1064
1064
|
#
|
1065
1065
|
# @param name [Symbol] The action name to define.
|
1066
|
-
# @param description [String] optional description for the action
|
1066
|
+
# @param description [String] optional description for the action. Used for
|
1067
|
+
# documentation generation.
|
1067
1068
|
# @param recipe_block The recipe to run when the action is taken. This block
|
1068
1069
|
# takes no parameters, and will be evaluated in a new context containing:
|
1069
1070
|
#
|
@@ -1076,11 +1077,8 @@ class Chef
|
|
1076
1077
|
def self.action(action, description: nil, &recipe_block)
|
1077
1078
|
action = action.to_sym
|
1078
1079
|
declare_action_class
|
1079
|
-
action_class.action(action, &recipe_block)
|
1080
|
+
action_class.action(action, description: description, &recipe_block)
|
1080
1081
|
self.allowed_actions += [ action ]
|
1081
|
-
# Accept any non-nil description, which will correctly override
|
1082
|
-
# any specific inherited description.
|
1083
|
-
action_descriptions[action] = description unless description.nil?
|
1084
1082
|
default_action action if Array(default_action) == [:nothing]
|
1085
1083
|
end
|
1086
1084
|
|
@@ -1090,18 +1088,15 @@ class Chef
|
|
1090
1088
|
# @param action [Symbol,String] the action name
|
1091
1089
|
# @return the description of the action provided, or nil if no description
|
1092
1090
|
# was defined
|
1093
|
-
def
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
def self.action_descriptions
|
1103
|
-
@action_descriptions ||=
|
1104
|
-
superclass.respond_to?(:action_descriptions) ? superclass.action_descriptions.dup : { nothing: nil }
|
1091
|
+
def action_description(action)
|
1092
|
+
provider_for_action(action).class.action_description(action)
|
1093
|
+
rescue Chef::Exceptions::ProviderNotFound
|
1094
|
+
# If a provider can't be found, there can be no description defined on the provider.
|
1095
|
+
nil
|
1096
|
+
rescue NameError => e
|
1097
|
+
# This can happen when attempting to load a provider in a platform-specific
|
1098
|
+
# environment where we have not required the necessary files yet
|
1099
|
+
raise unless e.message =~ /uninitialized constant/
|
1105
1100
|
end
|
1106
1101
|
|
1107
1102
|
# Define a method to load up this resource's properties with the current
|
@@ -1191,6 +1186,7 @@ class Chef
|
|
1191
1186
|
if superclass.custom_resource?
|
1192
1187
|
superclass.action_class
|
1193
1188
|
else
|
1189
|
+
|
1194
1190
|
ActionClass
|
1195
1191
|
end
|
1196
1192
|
|
@@ -23,6 +23,11 @@ require_relative "node"
|
|
23
23
|
require_relative "resources"
|
24
24
|
require_relative "json_compat"
|
25
25
|
|
26
|
+
# We need to require providers so that we can resolve
|
27
|
+
# action documentation that may have been defined on the providers
|
28
|
+
# instead of the resources.
|
29
|
+
require_relative "providers"
|
30
|
+
|
26
31
|
class Chef
|
27
32
|
module ResourceInspector
|
28
33
|
def self.get_default(default)
|
@@ -39,11 +44,10 @@ class Chef
|
|
39
44
|
def self.extract_resource(resource, complete = false)
|
40
45
|
data = {}
|
41
46
|
data[:description] = resource.description
|
42
|
-
# data[:deprecated] = resource.deprecated || false
|
43
47
|
data[:default_action] = resource.default_action
|
44
48
|
data[:actions] = {}
|
45
49
|
resource.allowed_actions.each do |action|
|
46
|
-
data[:actions][action] = resource.action_description(action)
|
50
|
+
data[:actions][action] = resource.new(resource.to_s, nil).action_description(action)
|
47
51
|
end
|
48
52
|
|
49
53
|
data[:examples] = resource.examples
|
data/lib/chef/resources.rb
CHANGED
@@ -58,6 +58,14 @@ require_relative "resource/ips_package"
|
|
58
58
|
require_relative "resource/gem_package"
|
59
59
|
require_relative "resource/scm/git"
|
60
60
|
require_relative "resource/group"
|
61
|
+
require_relative "resource/habitat/habitat_package"
|
62
|
+
require_relative "resource/habitat/habitat_sup"
|
63
|
+
require_relative "resource/habitat/habitat_sup_systemd"
|
64
|
+
require_relative "resource/habitat/habitat_sup_windows"
|
65
|
+
require_relative "resource/habitat_config"
|
66
|
+
require_relative "resource/habitat_install"
|
67
|
+
require_relative "resource/habitat_service"
|
68
|
+
require_relative "resource/habitat_user_toml"
|
61
69
|
require_relative "resource/http_request"
|
62
70
|
require_relative "resource/hostname"
|
63
71
|
require_relative "resource/homebrew_cask"
|
@@ -65,6 +73,8 @@ require_relative "resource/homebrew_package"
|
|
65
73
|
require_relative "resource/homebrew_tap"
|
66
74
|
require_relative "resource/homebrew_update"
|
67
75
|
require_relative "resource/ifconfig"
|
76
|
+
require_relative "resource/inspec_input"
|
77
|
+
require_relative "resource/inspec_waiver"
|
68
78
|
require_relative "resource/inspec_waiver_file_entry"
|
69
79
|
require_relative "resource/kernel_module"
|
70
80
|
require_relative "resource/ksh"
|
@@ -148,6 +158,8 @@ require_relative "resource/windows_ad_join"
|
|
148
158
|
require_relative "resource/windows_audit_policy"
|
149
159
|
require_relative "resource/windows_auto_run"
|
150
160
|
require_relative "resource/windows_certificate"
|
161
|
+
require_relative "resource/windows_defender"
|
162
|
+
require_relative "resource/windows_defender_exclusion"
|
151
163
|
require_relative "resource/windows_dfs_folder"
|
152
164
|
require_relative "resource/windows_dfs_namespace"
|
153
165
|
require_relative "resource/windows_dfs_server"
|
@@ -167,7 +179,8 @@ require_relative "resource/windows_share"
|
|
167
179
|
require_relative "resource/windows_shortcut"
|
168
180
|
require_relative "resource/windows_task"
|
169
181
|
require_relative "resource/windows_uac"
|
182
|
+
require_relative "resource/windows_update_settings"
|
170
183
|
require_relative "resource/windows_workgroup"
|
171
184
|
require_relative "resource/timezone"
|
172
185
|
require_relative "resource/windows_user_privilege"
|
173
|
-
require_relative "resource/windows_security_policy"
|
186
|
+
require_relative "resource/windows_security_policy"
|