Skip to content

Commit

Permalink
Merge pull request chef-boneyard#391 from chef-cookbooks/depre
Browse files Browse the repository at this point in the history
Remove reboot handler / require Chef 12.1+
  • Loading branch information
tas50 authored Sep 4, 2016
2 parents fb88e7b + 98e1d2d commit 27249ce
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 191 deletions.
41 changes: 1 addition & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,7 @@ Provides a set of Windows-specific primitives (Chef resources) meant to aid in t

### Chef

- Chef 12+

### Cookbooks

- chef_handler (`windows::reboot_handler` leverages the chef_handler LWRP)

## Attributes

- `node['windows']['allow_pending_reboots']` - used to configure the `WindowsRebootHandler` (via the `windows::reboot_handler` recipe) to act on pending reboots. default is true (ie act on pending reboots). The value of this attribute only has an effect if the `windows::reboot_handler` is in a node's run list.
- `node['windows']['allow_reboot_on_failure']` - used to register the `WindowsRebootHandler` (via the `windows::reboot_handler` recipe) as an exception handler too to act on reboots not only at the end of successful Chef runs, but even at the end of failed runs. default is false (ie reboot only after successful runs). The value of this attribute only has an effect if the `windows::reboot_handler` is in a node's run list.
- Chef 12.1+

## Resource/Provider

Expand Down Expand Up @@ -719,18 +710,6 @@ if is_package_installed?('Windows Software Development Kit')
end
```

## Exception/Report Handlers

### WindowsRebootHandler

Required reboots are a necessary evil of configuring and managing Windows nodes. This report handler (ie fires at the end of Chef runs) acts on requested (Chef initiated) or pending (as determined by the OS per configuration action we performed) reboots. The `allow_pending_reboots` initialization argument should be set to false if you do not want the handler to automatically reboot a node if it has been determined a reboot is pending. Reboots can still be requested explicitly via the `windows_reboot` LWRP.

### Initialization Arguments

- `allow_pending_reboots` - indicator on whether the handler should act on a the Window's 'pending reboot' state. default is true
- `timeout` - timeout delay in seconds to wait before proceeding with the reboot. default is 60 seconds
- `reason` - comment on the reason for the reboot. default is 'Chef Software Chef initiated reboot'

## Windows ChefSpec Matchers

The Windows cookbook includes custom [ChefSpec](https://github.com/sethvargo/chefspec) matchers you can use to test your own cookbooks that consume Windows cookbook LWRPs.
Expand Down Expand Up @@ -789,24 +768,6 @@ depends 'windows'

Convenience recipe that installs supporting gems for many of the resources/providers that ship with this cookbook.

### reboot_handler

Leverages the `chef_handler` LWRP to register the `WindowsRebootHandler` report handler that ships as part of this cookbook. By default this handler is set to automatically act on pending reboots. If you would like to change this behavior override `node['windows']['allow_pending_reboots']` and set the value to false. For example:

```ruby
name 'base'
description 'base role'
override_attributes(
'windows' => {
'allow_pending_reboots' => false
}
)
```

This will still allow a reboot to be explicitly requested via the `windows_reboot` LWRP.

By default, the handler will only be registered as a report handler, meaning that it will only fire at the end of successful Chef runs. If the run fails, pending or requested reboots will be ignored. This can lead to a situation where some package was installed and notified a reboot request via the `windows_reboot` LWRP, and then the run fails for some unrelated reason, and the reboot request gets dropped because the resource that notified the reboot request will already be up-to-date at the next run and will not request a reboot again, and thus the requested reboot will never be performed. To change this behavior and register the handler as an exception handler that fires at the end of failed runs too, override `node['windows']['allow_reboot_on_failure']` and set the value to true.

## License & Authors

- Author:: Seth Chisamore ([[email protected]](mailto:[email protected]))
Expand Down
3 changes: 0 additions & 3 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@
# limitations under the License.
#

default['windows']['allow_pending_reboots'] = true
default['windows']['allow_reboot_on_failure'] = false
default['windows']['rubyzipversion'] = nil
default['windows']['reboot_timeout'] = 60
83 changes: 0 additions & 83 deletions files/default/handlers/windows_reboot_handler.rb

This file was deleted.

2 changes: 1 addition & 1 deletion libraries/registry_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Provider:: registry
#
# Copyright:: 2010, VMware, Inc.
# Copyright:: 2011-2015, Chef Software, Inc.
# Copyright:: 2011-2016, Chef Software, Inc.
# Copyright:: 2011, Business Intelligence Associates, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion libraries/wmi_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Author:: Adam Edwards (<[email protected]>)
#
# Copyright:: 2014-2015, Chef Software, Inc.
# Copyright:: 2014-2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
3 changes: 1 addition & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
supports 'windows'
source_url 'https://github.com/chef-cookbooks/windows'
issues_url 'https://github.com/chef-cookbooks/windows/issues'
chef_version '>= 12.0' if respond_to?(:chef_version)
depends 'chef_handler'
chef_version '>= 12.1' if respond_to?(:chef_version)
2 changes: 1 addition & 1 deletion providers/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Cookbook Name:: windows
# Provider:: task
#
# Copyright:: 2012-2015, Chef Software, Inc.
# Copyright:: 2012-2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
32 changes: 0 additions & 32 deletions recipes/reboot_handler.rb

This file was deleted.

2 changes: 1 addition & 1 deletion resources/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
include Windows::Helper

actions :install, :remove, :delete
default_action :install

attribute :feature_name, kind_of: String, name_attribute: true
attribute :source, kind_of: String
attribute :all, kind_of: [TrueClass, FalseClass], default: false

def initialize(name, run_context = nil)
super
@action = :install
@provider = lookup_provider_constant(locate_default_provider)
end

Expand Down
5 changes: 1 addition & 4 deletions resources/printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
actions :create, :delete
default_action :create

attribute :device_id, kind_of: String, name_attribute: true,
required: true
attribute :device_id, kind_of: String, name_attribute: true, required: true
attribute :comment, kind_of: String

attribute :default, kind_of: [TrueClass, FalseClass], default: false
attribute :driver_name, kind_of: String, required: true
attribute :location, kind_of: String
attribute :shared, kind_of: [TrueClass, FalseClass], default: false
attribute :share_name, kind_of: String

attribute :ipv4_address, kind_of: String, regex: Resolv::IPv4::Regex

attr_accessor :exists
8 changes: 2 additions & 6 deletions resources/printer_port.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
actions :create, :delete
default_action :create

attribute :ipv4_address, name_attribute: true, kind_of: String,
required: true, regex: Resolv::IPv4::Regex

attribute :ipv4_address, name_attribute: true, kind_of: String, required: true, regex: Resolv::IPv4::Regex
attribute :port_name, kind_of: String
attribute :port_number, kind_of: Fixnum, default: 9100
attribute :port_description, kind_of: String
attribute :snmp_enabled, kind_of: [TrueClass, FalseClass],
default: false

attribute :snmp_enabled, kind_of: [TrueClass, FalseClass], default: false
attribute :port_protocol, kind_of: Fixnum, default: 1, equal_to: [1, 2]

attr_accessor :exists
7 changes: 1 addition & 6 deletions resources/shortcut.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

actions :create

default_action :create
default_action :create

attribute :name, kind_of: String
Expand All @@ -28,9 +29,3 @@
attribute :description, kind_of: String
attribute :cwd, kind_of: String
attribute :iconlocation, kind_of: String

# Covers 0.10.8 and earlier
def initialize(*args)
super
@action = :create
end
8 changes: 2 additions & 6 deletions resources/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Cookbook Name:: windows
# Resource:: task
#
# Copyright:: 2012-2015, Chef Software, Inc.
# Copyright:: 2012-2016, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@
# Passwords can't be loaded for existing tasks, making :modify both confusing
# and not very useful
actions :create, :delete, :run, :end, :change, :enable, :disable
default_action :create

attribute :task_name, kind_of: String, name_attribute: true, regex: [/\A[^\/\:\*\?\<\>\|]+\z/]
attribute :command, kind_of: String
Expand All @@ -47,8 +48,3 @@
attribute :idle_time, kind_of: Integer, default: nil

attr_accessor :exists, :status, :enabled

def initialize(name, run_context = nil)
super
@action = :create
end
6 changes: 1 addition & 5 deletions resources/zipfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@
#

actions :unzip, :zip
default_action :unzip

attribute :path, kind_of: String, name_attribute: true
attribute :source, kind_of: String
attribute :overwrite, kind_of: [TrueClass, FalseClass], default: false
attribute :checksum, kind_of: String

def initialize(name, run_context = nil)
super
@action = :unzip
end

0 comments on commit 27249ce

Please sign in to comment.