W3cubDocs

/Ansible

win_reg_stat - returns information about a Windows registry key or property of a key

New in version 2.3.

Synopsis

  • Like win_file, win_reg_stat will return whether the key/property exists.
  • It also returns the sub keys and properties of the key specified.
  • If specifying a property name through property, it will return the information specific for that property.

Options

parameter required default choices comments
name
no
The registry property name to get information for, the return json will not include the sub_keys and properties entries for the key specified.
aliases: entry, value, property
path
yes
The full registry key path including the hive to search for.
aliases: key

Examples

# Obtain information about a registry key using short form
- win_reg_stat:
    path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion
  register: current_version

# Obtain information about a registry key property
- win_reg_stat:
    path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion
    name: CommonFilesDir
  register: common_files_dir

Return Values

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

name description returned type sample
raw_value
Returns the raw value of the registry property, REG_EXPAND_SZ has no string expansion, REG_BINARY or REG_NONE is in hex 0x format. REG_NONE, this value is a hex string in the 0x format.
success, path/property exists and property specified string %ProgramDir%\\Common Files
sub_keys
A list of all the sub keys of the key specified.
success, path exists and property not specified list ['AppHost', 'Casting', 'DateTime']
exists
States whether the registry key/property exists.
success and path/property exists boolean True
changed
Whether anything was changed.
always boolean True
type
The property type.
success, path/property exists and property specified string REG_EXPAND_SZ
properties
A list of all the properties and their values in the key.
success, path exists and property not specified list [{'binary_property': {'raw_value': ['0x01', '0x16'], 'type': 'REG_BINARY', 'value': [1, 22]}}, {'multi_string_property': {'raw_value': ['a', 'b'], 'type': 'REG_MULTI_SZ', 'value': ['a', 'b']}}]
value
The value of the property.
success, path/property exists and property specified string C:\\Program Files\\Common Files

Status

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

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

© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/win_reg_stat_module.html