| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Copyright: (c) 2015, Adam Keech <[email protected]> |
| 5 |
# Copyright: (c) 2015, Josh Ludwig <[email protected]> |
| 6 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 7 |
|
| 8 |
# this is a windows documentation stub. actual code lives in the .ps1 |
| 9 |
# file of the same name |
| 10 |
|
| 11 |
ANSIBLE_METADATA = {'metadata_version': '1.1', |
| 12 |
'status': ['preview'], |
| 13 |
'supported_by': 'core'} |
| 14 |
|
| 15 |
|
| 16 |
DOCUMENTATION = r""" |
| 17 |
--- |
| 18 |
module: win_regedit |
| 19 |
version_added: '2.0' |
| 20 |
short_description: Add, change, or remove registry keys and values |
| 21 |
description: |
| 22 |
- Add, modify or remove registry keys and values. |
| 23 |
- More information about the windows registry from Wikipedia |
| 24 |
U(https://en.wikipedia.org/wiki/Windows_Registry). |
| 25 |
options: |
| 26 |
path: |
| 27 |
description: |
| 28 |
- Name of the registry path. |
| 29 |
- 'Should be in one of the following registry hives: HKCC, HKCR, HKCU, |
| 30 |
HKLM, HKU.' |
| 31 |
type: str |
| 32 |
required: yes |
| 33 |
aliases: [ key ] |
| 34 |
name: |
| 35 |
description: |
| 36 |
- Name of the registry entry in the above C(path) parameters. |
| 37 |
- If not provided, or empty then the '(Default)' property for the key will |
| 38 |
be used. |
| 39 |
type: str |
| 40 |
aliases: [ entry, value ] |
| 41 |
data: |
| 42 |
description: |
| 43 |
- Value of the registry entry C(name) in C(path). |
| 44 |
- If not specified then the value for the property will be null for the |
| 45 |
corresponding C(type). |
| 46 |
- Binary and None data should be expressed in a yaml byte array or as comma |
| 47 |
separated hex values. |
| 48 |
- An easy way to generate this is to run C(regedit.exe) and use the |
| 49 |
I(export) option to save the registry values to a file. |
| 50 |
- In the exported file, binary value will look like C(hex:be,ef,be,ef), the |
| 51 |
C(hex:) prefix is optional. |
| 52 |
- DWORD and QWORD values should either be represented as a decimal number |
| 53 |
or a hex value. |
| 54 |
- Multistring values should be passed in as a list. |
| 55 |
- See the examples for more details on how to format this data. |
| 56 |
type: str |
| 57 |
type: |
| 58 |
description: |
| 59 |
- The registry value data type. |
| 60 |
type: str |
| 61 |
choices: [ binary, dword, expandstring, multistring, string, qword ] |
| 62 |
default: string |
| 63 |
aliases: [ datatype ] |
| 64 |
state: |
| 65 |
description: |
| 66 |
- The state of the registry entry. |
| 67 |
type: str |
| 68 |
choices: [ absent, present ] |
| 69 |
default: present |
| 70 |
delete_key: |
| 71 |
description: |
| 72 |
- When C(state) is 'absent' then this will delete the entire key. |
| 73 |
- If C(no) then it will only clear out the '(Default)' property for |
| 74 |
that key. |
| 75 |
type: bool |
| 76 |
default: yes |
| 77 |
version_added: '2.4' |
| 78 |
hive: |
| 79 |
description: |
| 80 |
- A path to a hive key like C:\Users\Default\NTUSER.DAT to load in the |
| 81 |
registry. |
| 82 |
- This hive is loaded under the HKLM:\ANSIBLE key which can then be used |
| 83 |
in I(name) like any other path. |
| 84 |
- This can be used to load the default user profile registry hive or any |
| 85 |
other hive saved as a file. |
| 86 |
- Using this function requires the user to have the C(SeRestorePrivilege) |
| 87 |
and C(SeBackupPrivilege) privileges enabled. |
| 88 |
type: path |
| 89 |
version_added: '2.5' |
| 90 |
notes: |
| 91 |
- Check-mode C(-C/--check) and diff output C(-D/--diff) are supported, so that you can test every change against the active configuration before |
| 92 |
applying changes. |
| 93 |
- Beware that some registry hives (C(HKEY_USERS) in particular) do not allow to create new registry paths in the root folder. |
| 94 |
- Since ansible 2.4, when checking if a string registry value has changed, a case-sensitive test is used. Previously the test was case-insensitive. |
| 95 |
seealso: |
| 96 |
- module: win_reg_stat |
| 97 |
- module: win_regmerge |
| 98 |
author: |
| 99 |
- Adam Keech (@smadam813) |
| 100 |
- Josh Ludwig (@joshludwig) |
| 101 |
- Jordan Borean (@jborean93) |
| 102 |
""" |
| 103 |
|
| 104 |
EXAMPLES = r""" |
| 105 |
- name: Create registry path MyCompany |
| 106 |
win_regedit: |
| 107 |
path: HKCU:\Software\MyCompany |
| 108 |
|
| 109 |
- name: Add or update registry path MyCompany, with entry 'hello', and containing 'world' |
| 110 |
win_regedit: |
| 111 |
path: HKCU:\Software\MyCompany |
| 112 |
name: hello |
| 113 |
data: world |
| 114 |
|
| 115 |
- name: Add or update registry path MyCompany, with dword entry 'hello', and containing 1337 as the decimal value |
| 116 |
win_regedit: |
| 117 |
path: HKCU:\Software\MyCompany |
| 118 |
name: hello |
| 119 |
data: 1337 |
| 120 |
type: dword |
| 121 |
|
| 122 |
- name: Add or update registry path MyCompany, with dword entry 'hello', and containing 0xff2500ae as the hex value |
| 123 |
win_regedit: |
| 124 |
path: HKCU:\Software\MyCompany |
| 125 |
name: hello |
| 126 |
data: 0xff2500ae |
| 127 |
type: dword |
| 128 |
|
| 129 |
- name: Add or update registry path MyCompany, with binary entry 'hello', and containing binary data in hex-string format |
| 130 |
win_regedit: |
| 131 |
path: HKCU:\Software\MyCompany |
| 132 |
name: hello |
| 133 |
data: hex:be,ef,be,ef,be,ef,be,ef,be,ef |
| 134 |
type: binary |
| 135 |
|
| 136 |
- name: Add or update registry path MyCompany, with binary entry 'hello', and containing binary data in yaml format |
| 137 |
win_regedit: |
| 138 |
path: HKCU:\Software\MyCompany |
| 139 |
name: hello |
| 140 |
data: [0xbe,0xef,0xbe,0xef,0xbe,0xef,0xbe,0xef,0xbe,0xef] |
| 141 |
type: binary |
| 142 |
|
| 143 |
- name: Add or update registry path MyCompany, with expand string entry 'hello' |
| 144 |
win_regedit: |
| 145 |
path: HKCU:\Software\MyCompany |
| 146 |
name: hello |
| 147 |
data: '%appdata%\local' |
| 148 |
type: expandstring |
| 149 |
|
| 150 |
- name: Add or update registry path MyCompany, with multi string entry 'hello' |
| 151 |
win_regedit: |
| 152 |
path: HKCU:\Software\MyCompany |
| 153 |
name: hello |
| 154 |
data: ['hello', 'world'] |
| 155 |
type: multistring |
| 156 |
|
| 157 |
- name: Disable keyboard layout hotkey for all users (changes existing) |
| 158 |
win_regedit: |
| 159 |
path: HKU:\.DEFAULT\Keyboard Layout\Toggle |
| 160 |
name: Layout Hotkey |
| 161 |
data: 3 |
| 162 |
type: dword |
| 163 |
|
| 164 |
- name: Disable language hotkey for current users (adds new) |
| 165 |
win_regedit: |
| 166 |
path: HKCU:\Keyboard Layout\Toggle |
| 167 |
name: Language Hotkey |
| 168 |
data: 3 |
| 169 |
type: dword |
| 170 |
|
| 171 |
- name: Remove registry path MyCompany (including all entries it contains) |
| 172 |
win_regedit: |
| 173 |
path: HKCU:\Software\MyCompany |
| 174 |
state: absent |
| 175 |
delete_key: yes |
| 176 |
|
| 177 |
- name: Clear the existing (Default) entry at path MyCompany |
| 178 |
win_regedit: |
| 179 |
path: HKCU:\Software\MyCompany |
| 180 |
state: absent |
| 181 |
delete_key: no |
| 182 |
|
| 183 |
- name: Remove entry 'hello' from registry path MyCompany |
| 184 |
win_regedit: |
| 185 |
path: HKCU:\Software\MyCompany |
| 186 |
name: hello |
| 187 |
state: absent |
| 188 |
|
| 189 |
- name: Change default mouse trailing settings for new users |
| 190 |
win_regedit: |
| 191 |
path: HKLM:\ANSIBLE\Control Panel\Mouse |
| 192 |
name: MouseTrails |
| 193 |
data: 10 |
| 194 |
type: str |
| 195 |
state: present |
| 196 |
hive: C:\Users\Default\NTUSER.dat |
| 197 |
""" |
| 198 |
|
| 199 |
RETURN = r""" |
| 200 |
data_changed: |
| 201 |
description: Whether this invocation changed the data in the registry value. |
| 202 |
returned: success |
| 203 |
type: bool |
| 204 |
sample: false |
| 205 |
data_type_changed: |
| 206 |
description: Whether this invocation changed the datatype of the registry value. |
| 207 |
returned: success |
| 208 |
type: bool |
| 209 |
sample: true |
| 210 |
""" |