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
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Doug Ireton <doug@1strategy.com>
|
3
3
|
# Copyright:: 2012-2018, Nordstrom, Inc.
|
4
|
+
# Copyright:: Chef Software, Inc.
|
4
5
|
#
|
5
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
7
|
# you may not use this file except in compliance with the License.
|
@@ -68,14 +69,17 @@ class Chef
|
|
68
69
|
}
|
69
70
|
|
70
71
|
property :port_name, String,
|
71
|
-
description: "The port name."
|
72
|
+
description: "The port name.",
|
73
|
+
default: lazy { |x| "IP_#{x.ipv4_address}" },
|
74
|
+
default_description: "The resource block name or the ipv4_address prepended with IP_."
|
72
75
|
|
73
76
|
property :port_number, Integer,
|
74
|
-
description: "The port number.",
|
77
|
+
description: "The TCP port number.",
|
75
78
|
default: 9100
|
76
79
|
|
77
80
|
property :port_description, String,
|
78
|
-
|
81
|
+
desired_state: false,
|
82
|
+
deprecated: true
|
79
83
|
|
80
84
|
property :snmp_enabled, [TrueClass, FalseClass],
|
81
85
|
description: "Determines if SNMP is enabled on the port.",
|
@@ -86,79 +90,58 @@ class Chef
|
|
86
90
|
validation_message: "port_protocol must be either 1 for RAW or 2 for LPR!",
|
87
91
|
default: 1, equal_to: [1, 2]
|
88
92
|
|
89
|
-
PORTS_REG_KEY = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\\'.freeze unless defined?(PORTS_REG_KEY)
|
90
|
-
|
91
|
-
# @todo Set @current_resource port properties from registry
|
92
93
|
load_current_value do |new_resource|
|
93
|
-
|
94
|
-
ipv4_address new_resource.ipv4_address
|
95
|
-
port_name new_resource.port_name || "IP_#{new_resource.ipv4_address}"
|
96
|
-
end
|
97
|
-
|
98
|
-
action :create, description: "Create the printer port, if one doesn't already exist" do
|
99
|
-
description "Create the new printer port if it does not already exist."
|
100
|
-
|
101
|
-
if port_exists?
|
102
|
-
Chef::Log.info "#{@new_resource} already exists - nothing to do."
|
103
|
-
else
|
104
|
-
converge_by("Create #{@new_resource}") do
|
105
|
-
create_printer_port
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
94
|
+
port_data = powershell_exec(%Q{Get-WmiObject -Class Win32_TCPIPPrinterPort -Filter "Name='#{new_resource.port_name}'"}).result
|
109
95
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
if port_exists?
|
114
|
-
converge_by("Delete #{@new_resource}") do
|
115
|
-
delete_printer_port
|
116
|
-
end
|
96
|
+
if port_data.empty?
|
97
|
+
current_value_does_not_exist!
|
117
98
|
else
|
118
|
-
|
99
|
+
ipv4_address port_data["HostAddress"]
|
100
|
+
port_name port_data["Name"]
|
101
|
+
snmp_enabled port_data["SNMPEnabled"]
|
102
|
+
port_protocol port_data["Protocol"]
|
103
|
+
port_number port_data["PortNumber"]
|
119
104
|
end
|
120
105
|
end
|
121
106
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
SNMPEnabled = "$#{new_resource.snmp_enabled}";
|
148
|
-
}
|
107
|
+
action :create, description: "Create or update the printer port." do
|
108
|
+
converge_if_changed do
|
109
|
+
if current_resource
|
110
|
+
# update the printer port using PowerShell
|
111
|
+
powershell_exec! <<-EOH
|
112
|
+
Get-WmiObject Win32_TCPIPPrinterPort -EnableAllPrivileges -filter "Name='#{new_resource.port_name}'" |
|
113
|
+
ForEach-Object{
|
114
|
+
$_.HostAddress='#{new_resource.ipv4_address}'
|
115
|
+
$_.PortNumber='#{new_resource.port_number}'
|
116
|
+
$_.Protocol='#{new_resource.port_protocol}'
|
117
|
+
$_.SNMPEnabled='$#{new_resource.snmp_enabled}'
|
118
|
+
$_.Put()
|
119
|
+
}
|
120
|
+
EOH
|
121
|
+
else
|
122
|
+
# create the printer port using PowerShell
|
123
|
+
powershell_exec! <<-EOH
|
124
|
+
Set-WmiInstance -class Win32_TCPIPPrinterPort `
|
125
|
+
-EnableAllPrivileges `
|
126
|
+
-Argument @{ HostAddress = "#{new_resource.ipv4_address}";
|
127
|
+
Name = "#{new_resource.port_name}";
|
128
|
+
PortNumber = "#{new_resource.port_number}";
|
129
|
+
Protocol = "#{new_resource.port_protocol}";
|
130
|
+
SNMPEnabled = "$#{new_resource.snmp_enabled}";
|
131
|
+
}
|
149
132
|
EOH
|
150
133
|
end
|
151
|
-
end
|
152
134
|
|
153
|
-
|
154
|
-
|
135
|
+
end
|
136
|
+
end
|
155
137
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
EOH
|
138
|
+
action :delete, description: "Delete an existing printer port." do
|
139
|
+
if current_resource
|
140
|
+
converge_by("delete port #{new_resource.port_name}") do
|
141
|
+
powershell_exec!("Remove-PrinterPort -Name #{new_resource.port_name}")
|
161
142
|
end
|
143
|
+
else
|
144
|
+
Chef::Log.info "#{new_resource.port_name} doesn't exist - can't delete."
|
162
145
|
end
|
163
146
|
end
|
164
147
|
end
|
@@ -28,6 +28,7 @@ class Chef
|
|
28
28
|
|
29
29
|
# The valid policy_names options found here
|
30
30
|
# https://github.com/ChrisAWalker/cSecurityOptions under 'AccountSettings'
|
31
|
+
# This needs to be revisited - the list at the link above is non-exhaustive and is missing a couple of items
|
31
32
|
policy_names = %w{LockoutDuration
|
32
33
|
MaximumPasswordAge
|
33
34
|
MinimumPasswordAge
|
@@ -36,6 +37,8 @@ class Chef
|
|
36
37
|
PasswordHistorySize
|
37
38
|
LockoutBadCount
|
38
39
|
ResetLockoutCount
|
40
|
+
AuditPolicyChange
|
41
|
+
LockoutDuration
|
39
42
|
RequireLogonToChangePassword
|
40
43
|
ForceLogoffWhenHourExpire
|
41
44
|
NewAdministratorName
|
@@ -87,8 +90,8 @@ class Chef
|
|
87
90
|
current_state = load_security_options
|
88
91
|
|
89
92
|
if new_resource.secoption == "ResetLockoutCount"
|
90
|
-
if new_resource.secvalue.to_i >
|
91
|
-
raise Chef::Exceptions::ValidationFailed, "The \"ResetLockoutCount\" value cannot be greater than
|
93
|
+
if new_resource.secvalue.to_i > current_state["LockoutDuration"].to_i
|
94
|
+
raise Chef::Exceptions::ValidationFailed, "The \"ResetLockoutCount\" value cannot be greater than the value currently set for \"LockoutDuration\""
|
92
95
|
end
|
93
96
|
end
|
94
97
|
if (new_resource.secoption == "ResetLockoutCount" || new_resource.secoption == "LockoutDuration") && current_state["LockoutBadCount"] == "0"
|
@@ -115,13 +118,13 @@ class Chef
|
|
115
118
|
policy_line = "#{security_option} = \"#{security_value}\""
|
116
119
|
file.write("[Unicode]\r\nUnicode=yes\r\n[System Access]\r\n#{policy_line}\r\n[Version]\r\nsignature=\"$CHICAGO$\"\r\nRevision=1\r\n")
|
117
120
|
file.close
|
118
|
-
file_path = file.path.tr("/",
|
121
|
+
file_path = file.path.tr("/", "\\")
|
119
122
|
cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg #{file_path} /areas SECURITYPOLICY"
|
120
123
|
else
|
121
124
|
policy_line = "#{security_option} = #{security_value}"
|
122
125
|
file.write("[Unicode]\r\nUnicode=yes\r\n[System Access]\r\n#{policy_line}\r\n[Version]\r\nsignature=\"$CHICAGO$\"\r\nRevision=1\r\n")
|
123
126
|
file.close
|
124
|
-
file_path = file.path.tr("/",
|
127
|
+
file_path = file.path.tr("/", "\\")
|
125
128
|
cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg #{file_path} /areas SECURITYPOLICY"
|
126
129
|
end
|
127
130
|
shell_out!(cmd)
|
@@ -192,7 +192,7 @@ class Chef
|
|
192
192
|
name
|
193
193
|
end
|
194
194
|
|
195
|
-
action :create, description: "Create or modify a Windows share" do
|
195
|
+
action :create, description: "Create or modify a Windows share." do
|
196
196
|
# we do this here instead of requiring the property because :delete doesn't need path set
|
197
197
|
raise "No path property set" unless new_resource.path
|
198
198
|
|
@@ -216,7 +216,7 @@ class Chef
|
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
219
|
-
action :delete, description: "Delete an existing Windows share" do
|
219
|
+
action :delete, description: "Delete an existing Windows share." do
|
220
220
|
if current_resource.nil?
|
221
221
|
Chef::Log.debug("#{new_resource.share_name} does not exist - nothing to do")
|
222
222
|
else
|
@@ -69,7 +69,7 @@ class Chef
|
|
69
69
|
iconlocation(link.IconLocation)
|
70
70
|
end
|
71
71
|
|
72
|
-
action :create, description: "Create or modify a Windows shortcut" do
|
72
|
+
action :create, description: "Create or modify a Windows shortcut." do
|
73
73
|
converge_if_changed do
|
74
74
|
converge_by "creating shortcut #{new_resource.shortcut_name}" do
|
75
75
|
link = WIN32OLE.new("WScript.Shell").CreateShortcut(new_resource.shortcut_name)
|
@@ -49,7 +49,7 @@ class Chef
|
|
49
49
|
|
50
50
|
**Create a scheduled task to run every 2 days**:
|
51
51
|
|
52
|
-
```
|
52
|
+
```ruby
|
53
53
|
windows_task 'chef-client' do
|
54
54
|
command 'chef-client'
|
55
55
|
run_level :highest
|
@@ -549,7 +549,7 @@ class Chef
|
|
549
549
|
if @current_resource.exists
|
550
550
|
task.get_task(new_resource.task_name)
|
551
551
|
@current_resource.task = task
|
552
|
-
pathed_task_name = new_resource.task_name.start_with?(
|
552
|
+
pathed_task_name = new_resource.task_name.start_with?("\\") ? new_resource.task_name : "\\#{new_resource.task_name}"
|
553
553
|
@current_resource.task_name(pathed_task_name)
|
554
554
|
end
|
555
555
|
@current_resource
|
@@ -29,7 +29,7 @@ class Chef
|
|
29
29
|
examples <<~DOC
|
30
30
|
**Disable UAC prompts for the admin**:
|
31
31
|
|
32
|
-
```
|
32
|
+
```ruby
|
33
33
|
windows_uac 'Disable UAC prompts for the admin' do
|
34
34
|
enable_uac true
|
35
35
|
prompt_on_secure_desktop false
|
@@ -39,7 +39,7 @@ class Chef
|
|
39
39
|
|
40
40
|
**Disable UAC entirely**:
|
41
41
|
|
42
|
-
```
|
42
|
+
```ruby
|
43
43
|
windows_uac 'Disable UAC entirely' do
|
44
44
|
enable_uac false
|
45
45
|
end
|
@@ -72,9 +72,7 @@ class Chef
|
|
72
72
|
equal_to: %i{auto_deny secure_prompt_for_creds prompt_for_creds},
|
73
73
|
default: :prompt_for_creds
|
74
74
|
|
75
|
-
action :configure, description: "Configures UAC by setting registry keys at `HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System
|
76
|
-
description 'Configures UAC by setting registry keys at \'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\''
|
77
|
-
|
75
|
+
action :configure, description: "Configures UAC by setting registry keys at `HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System`." do
|
78
76
|
registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' do
|
79
77
|
values [{ name: "EnableLUA", type: :dword, data: bool_to_reg(new_resource.enable_uac) },
|
80
78
|
{ name: "ValidateAdminCodeSignatures", type: :dword, data: bool_to_reg(new_resource.require_signed_binaries) },
|
@@ -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
|