ansible.builtin.win_regedit (v2.3.3.0-1) — module

Add, change, or remove registry keys and values

| "added in version" 2.0 of ansible.builtin"

Authors: Adam Keech (@smadam813), Josh Ludwig (@joshludwig)

preview | supported by core

Install Ansible via pip

Install with pip install ansible==2.3.3.0.post1

Description

Add, modify or remove registry keys and values.

More information about the windows registry from Wikipedia (https://en.wikipedia.org/wiki/Windows_Registry).

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create registry path MyCompany
  win_regedit:
    path: HKCU:\Software\MyCompany
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add or update registry path MyCompany, with entry 'hello', and containing 'world'
  win_regedit:
    path: HKCU:\Software\MyCompany
    name: hello
    data: world
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Disable language hotkey for current users (adds new)
  win_regedit:
    path: HKCU:\Keyboard Layout\Toggle
    name: Language Hotkey
    data: 3
    type: dword
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove registry path MyCompany (including all entries it contains)
  win_regedit:
    path: HKCU:\Software\MyCompany
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove entry 'hello' from registry path MyCompany
  win_regedit:
    path: HKCU:\Software\MyCompany
    name: hello
    state: absent

Inputs

    
data:
    description:
    - Value of the registry entry C(name) in C(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 C(regedit.exe) and use the I(Export) option
      to save the registry values to a file.  In the exported file binary values will
      look like C(hex:be,ef,be,ef).  The C(hex:) prefix is optional.

name:
    aliases:
    - entry
    description:
    - Name of registry entry in C(path).
    - This is an entry in the above C(key) parameter.
    - If not provided, or empty we use the default name '(default)'

path:
    aliases:
    - key
    description:
    - Name of registry path.
    - 'Should be in one of the following registry hives: HKCC, HKCR, HKCU, HKLM, HKU.'
    required: true

type:
    aliases:
    - datatype
    choices:
    - binary
    - dword
    - expandstring
    - multistring
    - string
    - qword
    default: string
    description:
    - Registry value data type.

state:
    choices:
    - present
    - absent
    default: present
    description:
    - State of registry entry.

Outputs

data_changed:
  description: whether this invocation changed the data in the registry value
  returned: success
  sample: false
  type: boolean
data_type_changed:
  description: whether this invocation changed the datatype of the registry value
  returned: success
  sample: true
  type: boolean