Documentation

win_regedit - Add, change, or remove registry keys and values

New in version 2.0.

Synopsis

Options

parameter required default choices comments
data
no
Value of the registry entry name in path.
Binary data should be expressed a yaml byte array or as comma separated hex values. An easy way to generate this is to run regedit.exe and use the Export option to save the registry values to a file. In the exported file binary values will look like hex:be,ef,be,ef. The hex: prefix is optional.
name
no
Name of registry entry in path.
This is an entry in the above key parameter.
If not provided, or empty we use the default name '(default)'.

aliases: entry
path
yes
Name of registry path.
Should be in one of the following registry hives: HKCC, HKCR, HKCU, HKLM, HKU.

aliases: key
state
no present
  • present
  • absent
State of registry entry.
type
no string
  • binary
  • dword
  • expandstring
  • multistring
  • string
  • qword
Registry value data type.

aliases: datatype

Examples

- name: Create registry path MyCompany
  win_regedit:
    path: HKCU:\Software\MyCompany

- name: Add or update registry path MyCompany, with entry 'hello', and containing 'world'
  win_regedit:
    path: HKCU:\Software\MyCompany
    name: hello
    data: world

- name: Add or update registry path MyCompany, with entry 'hello', and containing 1337
  win_regedit:
    path: HKCU:\Software\MyCompany
    name: hello
    data: 1337
    type: dword

- name: Add or update registry path MyCompany, with entry 'hello', and containing binary data in hex-string format
  win_regedit:
    path: HKCU:\Software\MyCompany
    name: hello
    data: hex:be,ef,be,ef,be,ef,be,ef,be,ef
    type: binary

- name: Add or update registry path MyCompany, with entry 'hello', and containing binary data in yaml format
  win_regedit:
    path: HKCU:\Software\MyCompany
    name: hello
    data: [0xbe,0xef,0xbe,0xef,0xbe,0xef,0xbe,0xef,0xbe,0xef]
    type: binary

- name: Disable keyboard layout hotkey for all users (changes existing)
  win_regedit:
    path: HKU:\.DEFAULT\Keyboard Layout\Toggle
    name: Layout Hotkey
    data: 3
    type: dword

- name: Disable language hotkey for current users (adds new)
  win_regedit:
    path: HKCU:\Keyboard Layout\Toggle
    name: Language Hotkey
    data: 3
    type: dword

- name: Remove registry path MyCompany (including all entries it contains)
  win_regedit:
    path: HKCU:\Software\MyCompany
    state: absent

- name: Remove entry 'hello' from registry path MyCompany
  win_regedit:
    path: HKCU:\Software\MyCompany
    name: hello
    state: absent

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

name description returned type sample
data_changed whether this invocation changed the data in the registry value success boolean False
data_type_changed whether this invocation changed the datatype of the registry value success boolean True


Notes

Note

  • Check-mode -C/--check and diff output -D/--diff are supported, so that you can test every change against the active configuration before applying changes.
  • Beware that some registry hives (HKEY_USERS in particular) do not allow to create new registry paths.

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Support

This module is maintained by those with core commit privileges

For more information on what this means please read Module Support

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.