Version information
This version is compatible with:
- Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
- Puppet >= 7.0.0 < 9.0.0
Start using this module
Add this module to your Puppetfile:
mod 'puppet-windows_power', '4.0.0'
Learn more about managing modules with a PuppetfileDocumentation
puppet-windows_power
Module description
Puppet module for managing Windows hibernation settings, power schemes and power devices (or power request overrides respectively).
Setup, Usage, Reference
Summary:
- use class
windows_power
to manage Windows power devices (physical, logical and virtual); this wraps the defined typewindows_power::device
- use class
windows_power::hibernate
to manage Windows hibernate settings - use class
windows_power::scheme
to manage Windows power scheme - shipped fact
power_devices
contains all kind of system's power devices, their various wakeup capabilities and their power request overrides - shipped fact
power_schemes
contains the system's power schemes and their activation state
See REFERENCE.md for further details and practical examples.
Special notice for v4.0.0
Version 4.0.0 is a complete rewrite and modernization of the previous module and breaks with configuration compatibility.
It also drops support for legacy Windows systems and removes functionality targeting those legacy systems. If you have any of those systems in place (such as Windows XP or Windows Server 2008) don't update.
Limitations
Due to the nature of Windows' way to configure things, we can't just write a config file with desired settings and tell Windows to apply that (or something similar). As well we're not able to determine the current state of some settings (e.g. the timeouts in a power scheme) at all.
Therefore, some commands are applied with every Puppet run to ensure the desired state. Additionally, it might need more than one Puppet run to achieve the final state.
We know that this is very bad Puppet style and we did our best to keep this as minimal as possible. As well we put a lot of effort into making the module fail-safe (e.g. not configuring the wrong power scheme if a new one was created but hasn't been successfully activated yet) at the cost of "might need more than one run".
This module assumes that your system is not managed by an Active Directory controller. We have no way of testing what happens if your system (or parts of it including the power management) is controlled this way and you should use the AD's capabilities of managing power-things then anyways.
Also note that device names, scheme names and similar are subjected to localization (whyever ...). This means that you will have a device System timer
on an English system and a Systemzeitgeber
on a German system for example. Configuring devices and overrides in an environment with mixed installation languages is probably quite annoying as you will have to create different profiles for different languages with the corresponding device names.
If you have any ideas, suggestions, improvements ... please get in touch with us.
Development
Development happens on GitHub in the well known way (fork, PR, issue, etc.).
Please feel free to report problems, suggest improvements, drop new ideas or teach us how to handle things better.
Reference
Table of Contents
Classes
windows_power
: class to manage Windows power devices (physical, logical and virtual)windows_power::hibernate
: class to manage Windows hibernate settingswindows_power::scheme
: class to manage Windows power scheme
Defined types
windows_power::device
: defined type to manage a Windows power device (physical, logical and virtual)
Classes
windows_power
class to manage Windows power devices (physical, logical and virtual)
- See also
- windows_power::device
Examples
basic usage
class { 'windows_power':
devices => {
'HID-compliant mouse (001)' => {
enable_wake => true
},
'wmplayer.exe' => {
power_request_overrides => {
process => {
display => true,
awaymode => true
}
}
},
'Realtek PCIe GbE Family Controller' => {
enable_wake => false,
power_request_overrides => {
driver => {
display => true,
system => true
}
}
}
}
}
Parameters
The following parameters are available in the windows_power
class:
devices
Data type: Optional[Hash[String[1], Hash[Pattern[/^[a-z][a-z0-9_]*$/], Data, 1], 1]]
hash of devices/drivers/services/tools to manage and what/how
Default value: undef
windows_power::hibernate
class to manage Windows hibernate settings
Examples
disable hibernation system wide
class { 'windows_power::hibernate':
enable => false
}
enable hibernation with default settings
class { 'windows_power::hibernate':
enable => true
}
enable and configure hibernation
class { 'windows_power::hibernate':
enable => true,
hiberfile_size => 100,
hiberfile_type => 'full'
}
Parameters
The following parameters are available in the windows_power::hibernate
class:
enable
Data type: Boolean
enable/disable the hibernate feature
hiberfile_size
Data type: Optional[Integer[40, 100]]
set desired hiberfile size (percentage of total memory, 40-100)
Default value: undef
hiberfile_type
Data type: Optional[Enum['reduced', 'full']]
set desired hiberfile type (reduced
/full
)
Default value: undef
windows_power::scheme
class to manage Windows power scheme
Examples
activate the "High performance" system scheme
class { 'windows_power::scheme':
guid => '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'
}
activate the "Balanced" system scheme and set some monitor timeouts
class { 'windows_power::scheme':
guid => '381b4222-f694-41f0-9685-ff5bb260df2e',
settings => {
monitor-timeout-ac => 30,
monitor-timeout-dc => 10
}
}
create a custom template inheriting "High performance" and tweak on that
class { 'windows_power::scheme':
guid => 'a1582e9e-9c9d-46fd-afdf-4d989292a073',
label => 'really full power',
template => '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c',
settings => {
disk-timeout-ac => 0,
disk-timeout-dc => 0,
standby-timeout-ac => 0,
standby-timeout-dc => 0,
hibernate-timeout-ac => 0,
hibernate-timeout-dc => 0
}
}
Parameters
The following parameters are available in the windows_power::scheme
class:
guid
Data type: Pattern[/\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/]
GUID of the scheme to create/activate; to activate/handle an existing scheme (e.g. the ones provided by the system) don't define a template; to create (and activate and handle) a new scheme (derived from an existing one) define the template.
label
Data type: Optional[String[1]]
desired label/name/title of the scheme (optional, recommended for custom schemes)
Default value: undef
template
Data type: Optional[Pattern[/\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/]]
GUID of the template scheme to use for creating a new custom scheme (optional); if the template does not exist no action is performed; so it's safe to define a template that will appear later somehow.
Default value: undef
description
Data type: Optional[String[1]]
desired descriptive text of the scheme (optional)
Default value: undef
settings
Data type:
Optional[Hash[Enum[
'monitor-timeout-ac',
'monitor-timeout-dc',
'disk-timeout-ac',
'disk-timeout-dc',
'standby-timeout-ac',
'standby-timeout-dc',
'hibernate-timeout-ac',
'hibernate-timeout-dc'
], Integer[0], 1, 8]]
settings to change (optional); settings are applied to the active scheme and only if this matches the declared GUID; this way accidential configuration of the wrong scheme is avoided but it might need more than one puppet run to complete all tasks.
Default value: undef
Defined types
windows_power::device
defined type to manage a Windows power device (physical, logical and virtual)
Examples
let your mouse wake the system
windows_power::device { 'HID-compliant mouse (001)':
enable_wake => true
}
don't allow Windows media player to keep system from turning off the display or from going to away mode
windows_power::device { 'wmplayer.exe':
power_request_overrides => {
process => {
display => true,
awaymode => true
}
}
}
don't allow your network card to wake the system, keep your display turned on or keep the system active
windows_power::device { 'Realtek PCIe GbE Family Controller':
enable_wake => false,
power_request_overrides => {
driver => {
display => true,
system => true
}
}
}
delete all power request overrides for/from vpn service
windows_power::device { 'VPN Service':
power_request_overrides => {
service => {
system => false
}
}
}
Parameters
The following parameters are available in the windows_power::device
defined type:
device
Data type: String[1]
name of the device/driver/service/process to handle, defaulting to resource's title (no need to set this manually);
also see the shipped fact power_devices
!
note that the term "device" covers several things (due to the nature of Windows' power management):
- physical devices build in or connected to the machine (such as a network card or a mouse)
- logical devices or device groups (such as "HID-compliant system controller" or even "Volume (005)")
- drivers or driver groups (such as "High Definition Audio Device")
- services (e.g. your remote management software's service name)
- processes (e.g. "your_media_player.exe")
Default value: $title
enable_wake
Data type: Optional[Boolean]
allow (or prohibit) the device to wake the system from a sleep state;
devices capable of waking the system do have $facts['power_devices'][$device]['wake_programmable'] == true
;
devices currently allowed waking the system do have $facts['power_devices'][$device]['wake_armed'] == true
;
it's safe to set enable_wake => true
even if the device is not able to do;
defined type only activates wake-up functionality if the device is reported to be capable of doing so!
Default value: undef
power_request_overrides
Data type: Optional[Hash[Enum['service', 'process', 'driver'], Hash[Enum['display', 'system', 'awaymode'], Boolean, 1, 3], 1, 3]]
set (or delete) one or more power request overrides for the device (see Microsoft documentation about power requests and overrides);
note that not defining a request type is similar to setting it to false
but not defining any request type means "don't touch the
current state"; so explicitly setting (only) false
values makes it possible to delete request overrides set outside of Puppet!
see examples for clarity.
Default value: undef
Changelog
All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module.
v4.0.0 (2024-05-10)
This is a complete module rewrite/modernization (almost from scratch, but being inspired by what has been there before).
Beyond the Puppet language modernization (and corresponding module redesign) we can summarize the relevant (and breaking) changes as follows:
- drop support for legacy windows systems
- remove functionality targeting those legacy systems
- rework shell/powershell commands and codes accordingly
- correct datatypes and values to match up-to-date systems
- drop dependency to liamjbennett/puppet-win_facts
- update general dependencies/requirements
- add facts
power_schemes
andpower_devices
and structure the module around them
Breaking changes:
- great rework #54 (Lightning-)
- Drop Puppet 6 support #51 (bastelfreak)
- modulesync 2.7.0 and drop puppet 4 #33 (bastelfreak)
Closed issues:
- Settings can only be changed for the currently active scheme #36
- Use in-built Windows Facter facts #9
Merged pull requests:
- drop stdlib dependency #53 (Lightning-)
- Remove duplicate CONTRIBUTING.md file #38 (dhoppe)
v3.0.2 (2018-10-20)
Merged pull requests:
- modulesync 2.2.0 and allow puppet 6.x #28 (bastelfreak)
v3.0.1 (2018-09-06)
Merged pull requests:
- allow puppetlabs/stdlib 5.x #25 (bastelfreak)
- Remove docker nodesets #22 (bastelfreak)
- drop EOL OSs; fix puppet version range #21 (bastelfreak)
v3.0.0 (2017-11-17)
Merged pull requests:
- bump puppet version dependency to >= 4.7.1 \< 6.0.0 #17 (bastelfreak)
v2.0.0 (2017-02-11)
This is the last release with Puppet3 support!
- Drop of ruby187 support!
- Fix several rubocop issues
- rubocop: fix RSpec/ImplicitExpect
- Modulesync
2015-03-23 Release 1.0.0
- Initial module release to voxpupuli
* This Changelog was automatically generated by github_changelog_generator
Dependencies
- puppetlabs/powershell (>= 1.0.5 < 7.0.0)
- puppetlabs/pwshlib (>= 0.4.0 < 2.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2014 Liam Bennett (liamjbennett@gmail.com) Copyright 2023 markt.de GmbH & Co. KG Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.