chef 17.5.22 → 17.7.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -0
  3. data/chef.gemspec +1 -0
  4. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  5. data/lib/chef/chef_fs/path_utils.rb +1 -1
  6. data/lib/chef/data_collector/run_end_message.rb +1 -1
  7. data/lib/chef/dsl/reboot_pending.rb +1 -1
  8. data/lib/chef/exceptions.rb +10 -0
  9. data/lib/chef/provider/cron.rb +4 -1
  10. data/lib/chef/provider/git.rb +1 -1
  11. data/lib/chef/provider/ifconfig/debian.rb +1 -1
  12. data/lib/chef/provider/package/habitat.rb +1 -1
  13. data/lib/chef/provider/subversion.rb +5 -5
  14. data/lib/chef/resource/archive_file.rb +1 -1
  15. data/lib/chef/resource/chef_client_trusted_certificate.rb +1 -0
  16. data/lib/chef/resource/chocolatey_config.rb +1 -1
  17. data/lib/chef/resource/chocolatey_feature.rb +1 -1
  18. data/lib/chef/resource/chocolatey_source.rb +24 -2
  19. data/lib/chef/resource/directory.rb +1 -1
  20. data/lib/chef/resource/habitat_install.rb +5 -5
  21. data/lib/chef/resource/inspec_input.rb +7 -8
  22. data/lib/chef/resource/inspec_waiver.rb +7 -8
  23. data/lib/chef/resource/inspec_waiver_file_entry.rb +1 -1
  24. data/lib/chef/resource/kernel_module.rb +27 -2
  25. data/lib/chef/resource/macos_userdefaults.rb +45 -133
  26. data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
  27. data/lib/chef/resource/powershell_package_source.rb +234 -70
  28. data/lib/chef/resource/windows_auto_run.rb +1 -1
  29. data/lib/chef/resource/windows_dfs_namespace.rb +2 -2
  30. data/lib/chef/resource/windows_update_settings.rb +3 -3
  31. data/lib/chef/resource.rb +1 -1
  32. data/lib/chef/resource_reporter.rb +1 -1
  33. data/lib/chef/secret_fetcher/azure_key_vault.rb +62 -8
  34. data/lib/chef/secret_fetcher.rb +0 -1
  35. data/lib/chef/version.rb +1 -1
  36. data/lib/chef/win32/version.rb +2 -1
  37. data/spec/functional/dsl/reboot_pending_spec.rb +3 -3
  38. data/spec/functional/dsl/registry_helper_spec.rb +1 -1
  39. data/spec/functional/resource/dsc_script_spec.rb +2 -2
  40. data/spec/functional/resource/macos_userdefaults_spec.rb +119 -0
  41. data/spec/functional/resource/powershell_package_source_spec.rb +5 -6
  42. data/spec/functional/resource/registry_spec.rb +81 -81
  43. data/spec/functional/win32/registry_spec.rb +8 -8
  44. data/spec/unit/data_collector_spec.rb +24 -1
  45. data/spec/unit/dsl/reboot_pending_spec.rb +1 -1
  46. data/spec/unit/mixin/default_paths_spec.rb +1 -1
  47. data/spec/unit/mixin/securable_spec.rb +3 -3
  48. data/spec/unit/provider/cron_spec.rb +45 -0
  49. data/spec/unit/provider/package/rubygems_spec.rb +5 -5
  50. data/spec/unit/provider/package/windows_spec.rb +1 -1
  51. data/spec/unit/provider/registry_key_spec.rb +4 -4
  52. data/spec/unit/provider/service/windows_spec.rb +5 -5
  53. data/spec/unit/provider/subversion_spec.rb +4 -4
  54. data/spec/unit/provider/windows_env_spec.rb +1 -1
  55. data/spec/unit/provider/zypper_repository_spec.rb +1 -1
  56. data/spec/unit/resource/chef_client_trusted_certificate_spec.rb +14 -0
  57. data/spec/unit/resource/chocolatey_config_spec.rb +1 -1
  58. data/spec/unit/resource/chocolatey_feature_spec.rb +1 -1
  59. data/spec/unit/resource/chocolatey_source_spec.rb +1 -1
  60. data/spec/unit/resource/kernel_module_spec.rb +2 -1
  61. data/spec/unit/resource/macos_user_defaults_spec.rb +36 -96
  62. data/spec/unit/resource/powershell_package_source_spec.rb +63 -62
  63. data/spec/unit/resource/registry_key_spec.rb +10 -10
  64. data/spec/unit/resource/windows_auto_run_spec.rb +1 -1
  65. data/spec/unit/resource/windows_feature_powershell_spec.rb +1 -1
  66. data/spec/unit/resource/windows_firewall_rule_spec.rb +2 -2
  67. data/spec/unit/resource/windows_task_spec.rb +3 -3
  68. data/spec/unit/resource_reporter_spec.rb +2 -2
  69. data/spec/unit/resource_spec.rb +5 -0
  70. data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +99 -20
  71. data/spec/unit/util/backup_spec.rb +1 -1
  72. data/spec/unit/win32/registry_spec.rb +3 -3
  73. metadata +21 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfe0cb34ad720e2647118256d4260f209cd36d73e6ccedf079a67489963901c1
4
- data.tar.gz: bc5229775dbb96f3f61cf2d11dfa16de3c0e2de6567169ed11cea54502a18679
3
+ metadata.gz: c14c01fc55c7847b27979c41e01be0dd845b69840fc048e7abeb8787156bae23
4
+ data.tar.gz: 44676d2fe03cc4306efaa4c33f48a9eb3e2d6d736962bcd441ffc4bd0c371621
5
5
  SHA512:
6
- metadata.gz: afce77f4964d02364b91be0128053ac2f866a41225308dd68d857d468c660d774450d95926e86615818791a37c9c6930c1ed1fdae4145f483f35dd633413ae1d
7
- data.tar.gz: 8db608f6151726772e05ac054fb31d37da4e21e16101f383d70eed9622d88b1362573e56d2eed50b38cd7fd5258631d3b99db7f9f6e26415d9a48a751a4a78a7
6
+ metadata.gz: 768707842ce349798c256c91d2202c5c7b7f931d63ca53eb9454ed6b424f3a11b38b2c9b94c4c4177959ff179029831a9cca3d3233afa5d2ba7dcd90afba3c23
7
+ data.tar.gz: 9a3a715294581c43a663387a3462c745d6bab3a44736ab9bf87e607cfa5cfa7a920de90a918225e05b08a8962b52103c792d97b586d69ef32023afb1e45dc11c
data/Gemfile CHANGED
@@ -39,6 +39,11 @@ group(:ruby_shadow) do
39
39
  gem "ruby-shadow", git: "https://github.com/chef/ruby-shadow", branch: "lcg/ruby-3.0", platforms: :ruby
40
40
  end
41
41
 
42
+ # deps that cannot be put in the knife gem because they require a compiler and fail on windows nodes
43
+ group(:knife_windows_deps) do
44
+ gem "ed25519", "~> 1.2" # ed25519 ssh key support
45
+ end
46
+
42
47
  group(:development, :test) do
43
48
  gem "rake"
44
49
  gem "rspec"
data/chef.gemspec CHANGED
@@ -52,6 +52,7 @@ Gem::Specification.new do |s|
52
52
  s.add_dependency "addressable"
53
53
  s.add_dependency "syslog-logger", "~> 1.6"
54
54
  s.add_dependency "uuidtools", ">= 2.1.5", "< 3.0" # osx_profile resource
55
+ s.add_dependency "corefoundation", "~> 0.3.4" # macos_userdefaults resource
55
56
 
56
57
  s.add_dependency "proxifier", "~> 1.0"
57
58
 
@@ -276,7 +276,7 @@ class Chef
276
276
  regexp << ".*"
277
277
  when "*"
278
278
  exact = nil
279
- regexp << '[^\/]*'
279
+ regexp << "[^\\/]*"
280
280
  when "?"
281
281
  exact = nil
282
282
  regexp << "."
@@ -58,7 +58,7 @@ class Chef
58
58
  end
59
59
 
60
60
  def self.regexp_path_separator
61
- ChefUtils.windows? ? '[\/\\\\]' : "/"
61
+ ChefUtils.windows? ? "[\\/\\\\]" : "/"
62
62
  end
63
63
 
64
64
  # Given a server path, determines if it is absolute.
@@ -128,7 +128,7 @@ class Chef
128
128
 
129
129
  if new_resource.cookbook_name
130
130
  hash["cookbook_name"] = new_resource.cookbook_name
131
- hash["cookbook_version"] = new_resource.cookbook_version.version
131
+ hash["cookbook_version"] = new_resource.cookbook_version&.version
132
132
  hash["recipe_name"] = new_resource.recipe_name
133
133
  end
134
134
 
@@ -37,7 +37,7 @@ class Chef
37
37
  # due to a file being in use (usually a temporary file and a system file)
38
38
  # \??\c:\temp\test.sys!\??\c:\winnt\system32\test.sys
39
39
  # http://technet.microsoft.com/en-us/library/cc960241.aspx
40
- registry_value_exists?('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { name: "PendingFileRenameOperations" }) ||
40
+ registry_value_exists?("HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager", { name: "PendingFileRenameOperations" }) ||
41
41
 
42
42
  # RebootRequired key contains Update IDs with a value of 1 if they require a reboot.
43
43
  # The existence of RebootRequired alone is sufficient on my Windows 8.1 workstation in Windows Update
@@ -308,6 +308,16 @@ class Chef
308
308
  super("No secret service provided. Supported services are: :#{fetcher_service_names.join(" :")}")
309
309
  end
310
310
  end
311
+
312
+ class Azure
313
+ class IdentityNotFound < RuntimeError
314
+ def initialize
315
+ super("The managed identity could not be found. This could mean one of the following things:\n\n" \
316
+ " 1. The VM has no system or user assigned identities.\n" \
317
+ " 2. The managed identity object_id or client_id that was specified is not assigned to the VM.\n")
318
+ end
319
+ end
320
+ end
311
321
  end
312
322
 
313
323
  # Exception class for collecting multiple failures. Used when running
@@ -100,7 +100,10 @@ class Chef
100
100
  newcron = get_crontab_entry
101
101
 
102
102
  if @cron_exists
103
- unless cron_different?
103
+ # Only compare the crontab if the current resource has a set command.
104
+ # This may not be set in cases where the Chef comment exists but the
105
+ # crontab command was commented out.
106
+ if current_resource.property_is_set?(:command) && !cron_different?
104
107
  logger.debug("#{new_resource}: Skipping existing cron entry")
105
108
  return
106
109
  end
@@ -28,7 +28,7 @@ class Chef
28
28
  extend Forwardable
29
29
  provides :git
30
30
 
31
- GIT_VERSION_PATTERN = Regexp.compile('git version (\d+\.\d+.\d+)')
31
+ GIT_VERSION_PATTERN = Regexp.compile("git version (\\d+\\.\\d+.\\d+)")
32
32
 
33
33
  def_delegator :new_resource, :destination, :cwd
34
34
 
@@ -87,7 +87,7 @@ iface <%= new_resource.device %> <%= new_resource.family %> static
87
87
  directory INTERFACES_DOT_D_DIR
88
88
 
89
89
  # roll our own file_edit resource, this will not get reported until we have a file_edit resource
90
- interfaces_dot_d_for_regexp = INTERFACES_DOT_D_DIR.gsub(/\./, '\.') # escape dots for the regexp
90
+ interfaces_dot_d_for_regexp = INTERFACES_DOT_D_DIR.gsub(/\./, "\\.") # escape dots for the regexp
91
91
  regexp = %r{^\s*source\s+#{interfaces_dot_d_for_regexp}/\*\s*$}
92
92
 
93
93
  return if ::File.exist?(INTERFACES_FILE) && regexp.match(IO.read(INTERFACES_FILE))
@@ -108,7 +108,7 @@ class Chef
108
108
  headers["Authorization"] = "Bearer #{new_resource.auth_token}" if new_resource.auth_token
109
109
 
110
110
  Chef::JSONCompat.parse(http.get(url, headers))
111
- rescue Net::HTTPServerException
111
+ rescue Net::HTTPClientException
112
112
  nil
113
113
  end
114
114
  end
@@ -58,7 +58,7 @@ class Chef
58
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
- shell_out!(checkout_command, run_options)
61
+ shell_out!(checkout_command, **run_options)
62
62
  end
63
63
  else
64
64
  logger.debug "#{new_resource} checkout destination #{new_resource.destination} already exists or is a non-empty directory - nothing to do"
@@ -75,7 +75,7 @@ class Chef
75
75
 
76
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
- shell_out!(export_command, run_options)
78
+ shell_out!(export_command, **run_options)
79
79
  end
80
80
  end
81
81
 
@@ -86,7 +86,7 @@ class Chef
86
86
  logger.trace "#{new_resource} current revision: #{current_rev} target revision: #{revision_int}"
87
87
  unless current_revision_matches_target_revision?
88
88
  converge_by("sync #{new_resource.destination} from #{new_resource.repository}") do
89
- shell_out!(sync_command, run_options)
89
+ shell_out!(sync_command, **run_options)
90
90
  logger.info "#{new_resource} updated to revision: #{revision_int}"
91
91
  end
92
92
  end
@@ -125,7 +125,7 @@ class Chef
125
125
  new_resource.revision
126
126
  else
127
127
  command = scm(:info, new_resource.repository, new_resource.svn_info_args, authentication, "-r#{new_resource.revision}")
128
- svn_info = shell_out!(command, run_options(cwd: cwd, returns: [0, 1])).stdout
128
+ svn_info = shell_out!(command, **run_options(cwd: cwd, returns: [0, 1])).stdout
129
129
 
130
130
  extract_revision_info(svn_info)
131
131
  end
@@ -137,7 +137,7 @@ class Chef
137
137
  return nil unless ::File.exist?(::File.join(new_resource.destination, ".svn"))
138
138
 
139
139
  command = scm(:info)
140
- svn_info = shell_out!(command, run_options(cwd: cwd, returns: [0, 1])).stdout
140
+ svn_info = shell_out!(command, **run_options(cwd: cwd, returns: [0, 1])).stdout
141
141
 
142
142
  extract_revision_info(svn_info)
143
143
  end
@@ -82,7 +82,7 @@ class Chef
82
82
  default: false
83
83
 
84
84
  property :strip_components, Integer,
85
- description: "Remove the specified number of leading path elements. Pathnames with fewer elements will be silently skipped. This behaves similarly to tar's --strip-components command line argument.",
85
+ description: "Remove the specified number of leading path elements. Pathnames with fewer elements will be silently skipped. This behaves similarly to tar's --strip-components command line argument.",
86
86
  introduced: "17.5",
87
87
  default: 0
88
88
 
@@ -75,6 +75,7 @@ class Chef
75
75
  file cert_path do
76
76
  content new_resource.certificate
77
77
  mode "0640"
78
+ sensitive new_resource.sensitive
78
79
  end
79
80
  end
80
81
 
@@ -21,7 +21,7 @@ class Chef
21
21
 
22
22
  provides :chocolatey_config
23
23
 
24
- description "Use the **chocolatey_config** resource to add or remove Chocolatey configuration keys."
24
+ description "Use the **chocolatey_config** resource to add or remove Chocolatey configuration keys. Note: The Chocolatey package manager is not installed on Windows by default. You will need to install it prior to using this resource by adding the [Chocolatey cookbook](https://supermarket.chef.io/cookbooks/chocolatey/) to your node's run list."
25
25
  introduced "14.3"
26
26
  examples <<~DOC
27
27
  **Set the Chocolatey cacheLocation config**:
@@ -20,7 +20,7 @@ class Chef
20
20
  unified_mode true
21
21
  provides :chocolatey_feature
22
22
 
23
- description "Use the **chocolatey_feature** resource to enable and disable Chocolatey features."
23
+ description "Use the **chocolatey_feature** resource to enable and disable Chocolatey features. Note: The Chocolatey package manager is not installed on Windows by default. You will need to install it prior to using this resource by adding the [Chocolatey cookbook](https://supermarket.chef.io/cookbooks/chocolatey/) to your node's run list."
24
24
  introduced "15.1"
25
25
  examples <<~DOC
26
26
  **Enable the checksumFiles Chocolatey feature**
@@ -20,7 +20,7 @@ class Chef
20
20
  unified_mode true
21
21
  provides :chocolatey_source
22
22
 
23
- description "Use the **chocolatey_source** resource to add, remove, enable, or disable Chocolatey sources."
23
+ description "Use the **chocolatey_source** resource to add, remove, enable, or disable Chocolatey sources. Note: The Chocolatey package manager is not installed on Windows by default. You will need to install it prior to using this resource by adding the [Chocolatey cookbook](https://supermarket.chef.io/cookbooks/chocolatey/) to your node's run list."
24
24
  introduced "14.3"
25
25
  examples <<~DOC
26
26
  **Add a Chocolatey source**
@@ -63,6 +63,22 @@ class Chef
63
63
 
64
64
  property :disabled, [TrueClass, FalseClass], default: false, desired_state: false, skip_docs: true
65
65
 
66
+ property :username, String,
67
+ description: "The username to use when authenticating against the source",
68
+ introduced: "17.7"
69
+
70
+ property :password, String, sensitive: true, desired_state: false,
71
+ description: "The password to use when authenticating against the source",
72
+ introduced: "17.7"
73
+
74
+ property :cert, String,
75
+ description: "The certificate to use when authenticating against the source",
76
+ introduced: "17.7"
77
+
78
+ property :cert_password, String, sensitive: true, desired_state: false,
79
+ description: "The password for the certificate to use when authenticating against the source",
80
+ introduced: "17.7"
81
+
66
82
  load_current_value do
67
83
  element = fetch_source_element(source_name)
68
84
  current_value_does_not_exist! if element.nil?
@@ -74,6 +90,8 @@ class Chef
74
90
  allow_self_service element["selfService"] == "true"
75
91
  priority element["priority"].to_i
76
92
  disabled element["disabled"] == "true"
93
+ username element["user"]
94
+ cert element["certificate"]
77
95
  end
78
96
 
79
97
  # @param [String] id the source name
@@ -129,10 +147,14 @@ class Chef
129
147
  def choco_cmd(action)
130
148
  cmd = "#{ENV["ALLUSERSPROFILE"]}\\chocolatey\\bin\\choco source #{action} -n \"#{new_resource.source_name}\""
131
149
  if action == "add"
132
- cmd << " -s #{new_resource.source} --priority=#{new_resource.priority}"
150
+ cmd << " --source=\"#{new_resource.source}\" --priority=#{new_resource.priority}"
133
151
  cmd << " --bypassproxy" if new_resource.bypass_proxy
134
152
  cmd << " --allowselfservice" if new_resource.allow_self_service
135
153
  cmd << " --adminonly" if new_resource.admin_only
154
+ cmd << " --user=\"#{new_resource.username}\"" if new_resource.username
155
+ cmd << " --password=\"#{new_resource.password}\"" if new_resource.password
156
+ cmd << " --cert=\"#{new_resource.cert}\"" if new_resource.cert
157
+ cmd << " --certpassword=\"#{new_resource.cert_password}\"" if new_resource.cert_password
136
158
  end
137
159
  cmd
138
160
  end
@@ -46,7 +46,7 @@ class Chef
46
46
  description: "The path to the directory. Using a fully qualified path is recommended, but is not always required."
47
47
 
48
48
  property :recursive, [ TrueClass, FalseClass ],
49
- description: "Create or delete parent directories recursively. For the owner, group, and mode properties, the value of this property applies only to the leaf directory.",
49
+ description: "Create parent directories recursively, or delete directory and all children recursively. For the owner, group, and mode properties, the value of this property applies only to the leaf directory.",
50
50
  default: false
51
51
  end
52
52
  end
@@ -52,8 +52,8 @@ class Chef
52
52
  property :name, String, default: "install habitat",
53
53
  description: "Name of the resource block. This has no impact other than logging."
54
54
 
55
- property :install_url, String, default: "https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh",
56
- description: "URL to the install script, default is from the [habitat repo](https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh) ."
55
+ property :install_url, String, default: "https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh",
56
+ description: "URL to the install script, default is from the [habitat repo](https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh) ."
57
57
 
58
58
  property :bldr_url, String,
59
59
  description: "Optional URL to an alternate Habitat Builder."
@@ -95,10 +95,10 @@ class Chef
95
95
  path habfile
96
96
  destination "#{Chef::Config[:file_cache_path]}/habitat"
97
97
  action :extract
98
- not_if { ::Dir.exist?('c:\habitat') }
98
+ not_if { ::Dir.exist?("c:\\habitat") }
99
99
  end
100
100
 
101
- directory 'c:\habitat' do
101
+ directory "c:\\habitat" do
102
102
  notifies :run, "powershell_script[installing from archive]", :immediately
103
103
  end
104
104
 
@@ -110,7 +110,7 @@ class Chef
110
110
  end
111
111
 
112
112
  # TODO: This won't self heal if missing until the next upgrade
113
- windows_path 'C:\habitat' do
113
+ windows_path "C:\\habitat" do
114
114
  action :add
115
115
  end
116
116
  else
@@ -56,13 +56,13 @@ class Chef
56
56
  end
57
57
  ```
58
58
 
59
- **Add an InSpec input to the Compliance Phase using a TOML, JSON or YAML file**:
59
+ **Add an InSpec input to the Compliance Phase using a TOML, JSON, or YAML file**:
60
60
 
61
61
  ```ruby
62
62
  inspec_input "/path/to/my/input.yml"
63
63
  ```
64
64
 
65
- **Add an InSpec input to the Compliance Phase using a TOML, JSON or YAML file, using the 'name' property**:
65
+ **Add an InSpec input to the Compliance Phase using a TOML, JSON, or YAML file, using the 'name' property**:
66
66
 
67
67
  ```ruby
68
68
  inspec_input "setting my input" do
@@ -70,12 +70,11 @@ class Chef
70
70
  end
71
71
  ```
72
72
 
73
- Note that the inspec_input resource does not update and will not fire notifications (similar to the log resource). This is done to preserve the ability to use
74
- the resource while not causing the updated resource count to be larger than zero. Since the resource does not update the state of the node being managed this
75
- behavior is still consistent with the configuration management model. Events should be used to observe configuration changes for the compliance phase. It is
76
- possible to use the `notify_group` resource to chain notifications of the two resources, but notifications are the wrong model to use and pure ruby conditionals
77
- should be used instead. Compliance configuration should be independent of other resources and should only be made conditional based on state/attributes not
78
- on other resources.
73
+ Note that the **inspec_input** resource does not update and will not fire notifications (similar to the log resource). This is done to preserve the ability to use
74
+ the resource while not causing the updated resource count to be larger than zero. Since the resource does not update the state of the managed node, this behavior
75
+ is still consistent with the configuration management model. Instead, you should use events to observe configuration changes for the compliance phase. It is
76
+ possible to use the `notify_group` resource to chain notifications of the two resources, but notifications are the wrong model to use, and you should use pure ruby
77
+ conditionals instead. Compliance configuration should be independent of other resources and should only be conditional based on state/attributes, not other resources.
79
78
  DOC
80
79
 
81
80
  property :name, [ Hash, String ]
@@ -62,7 +62,7 @@ class Chef
62
62
  end
63
63
  ```
64
64
 
65
- **Add an InSpec waiver to the Compliance Phase using an arbitrary YAML, JSON or TOML file**:
65
+ **Add an InSpec waiver to the Compliance Phase using an arbitrary YAML, JSON, or TOML file**:
66
66
 
67
67
  ```ruby
68
68
  # files ending in .yml or .yaml that exist are parsed as YAML
@@ -101,12 +101,11 @@ class Chef
101
101
  end
102
102
  ```
103
103
 
104
- Note that the inspec_waiver resource does not update and will not fire notifications (similar to the log resource). This is done to preserve the ability to use
105
- the resource while not causing the updated resource count to be larger than zero. Since the resource does not update the state of the node being managed this
106
- behavior is still consistent with the configuration management model. Events should be used to observe configuration changes for the compliance phase. It is
107
- possible to use the `notify_group` resource to chain notifications of the two resources, but notifications are the wrong model to use and pure ruby conditionals
108
- should be used instead. Compliance configuration should be independent of other resources and should only be made conditional based on state/attributes not
109
- on other resources.
104
+ Note that the **inspec_waiver** resource does not update and will not fire notifications (similar to the log resource). This is done to preserve the ability to use
105
+ the resource while not causing the updated resource count to be larger than zero. Since the resource does not update the state of the managed node, this behavior
106
+ is still consistent with the configuration management model. Instead, you should use events to observe configuration changes for the compliance phase. It is
107
+ possible to use the `notify_group` resource to chain notifications of the two resources, but notifications are the wrong model to use, and you should use pure ruby
108
+ conditionals instead. Compliance configuration should be independent of other resources and should only be conditional based on state/attributes, not other resources.
110
109
  DOC
111
110
 
112
111
  property :control, String,
@@ -117,7 +116,7 @@ class Chef
117
116
  description: "The expiration date of the waiver - provided in YYYY-MM-DD format",
118
117
  callbacks: {
119
118
  "Expiration date should be a valid calendar date and match the following format: YYYY-MM-DD" => proc { |e|
120
- re = Regexp.new('\d{4}-\d{2}-\d{2}$').freeze
119
+ re = Regexp.new("\\d{4}-\\d{2}-\\d{2}$").freeze
121
120
  if re.match?(e)
122
121
  Date.valid_date?(*e.split("-").map(&:to_i))
123
122
  else
@@ -74,7 +74,7 @@ class Chef
74
74
  description: "The expiration date of the given waiver - provided in YYYY-MM-DD format",
75
75
  callbacks: {
76
76
  "Expiration date should be a valid calendar date and match the following format: YYYY-MM-DD" => proc { |e|
77
- re = Regexp.new('\d{4}-\d{2}-\d{2}$').freeze
77
+ re = Regexp.new("\\d{4}-\\d{2}-\\d{2}$").freeze
78
78
  if re.match?(e)
79
79
  Date.valid_date?(*e.split("-").map(&:to_i))
80
80
  else
@@ -15,7 +15,7 @@ class Chef
15
15
 
16
16
  provides :kernel_module
17
17
 
18
- description "Use the **kernel_module** resource to manage kernel modules on Linux systems. This resource can load, unload, blacklist, disable, install, and uninstall modules."
18
+ description "Use the **kernel_module** resource to manage kernel modules on Linux systems. This resource can load, unload, blacklist, disable, enable, install, and uninstall modules."
19
19
  introduced "14.3"
20
20
  examples <<~DOC
21
21
  Install and load a kernel module, and ensure it loads on reboot.
@@ -68,13 +68,21 @@ class Chef
68
68
  end
69
69
  ```
70
70
 
71
- Disable a kernel module.
71
+ Disable a kernel module so that it is not installable.
72
72
 
73
73
  ```ruby
74
74
  kernel_module 'loop' do
75
75
  action :disable
76
76
  end
77
77
  ```
78
+
79
+ Enable a kernel module so that it is can be installed. Does not load or install.
80
+
81
+ ```ruby
82
+ kernel_module 'loop' do
83
+ action :enable
84
+ end
85
+ ```
78
86
  DOC
79
87
 
80
88
  property :modname, String,
@@ -101,6 +109,9 @@ class Chef
101
109
  end
102
110
  end
103
111
 
112
+ # Remove the "disable file" before trying to install
113
+ action_enable
114
+
104
115
  # create options file before loading the module
105
116
  unless new_resource.options.nil?
106
117
  file "#{new_resource.unload_dir}/options_#{new_resource.modname}.conf" do
@@ -178,6 +189,20 @@ class Chef
178
189
  action_unload
179
190
  end
180
191
 
192
+ action :enable, description: "Enable a kernel module. Reverse :disable actions" do
193
+ with_run_context :root do
194
+ find_resource(:execute, "update initramfs") do
195
+ command initramfs_command
196
+ action :nothing
197
+ end
198
+ end
199
+
200
+ file "#{new_resource.unload_dir}/disable_#{new_resource.modname}.conf" do
201
+ action :delete
202
+ notifies :run, "execute[update initramfs]", :delayed
203
+ end
204
+ end
205
+
181
206
  action :load, description: "Load a kernel module." do
182
207
  unless module_loaded?
183
208
  converge_by("load kernel module #{new_resource.modname}") do