Debian Codegraph @

ansible_collections/community/windows/plugins/modules/win_regmerge.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2015, Jon Hawkesworth (@jhawkesworth) <[email protected]>
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 DOCUMENTATION = r'''
8 ---
9 module: win_regmerge
10 short_description: Merges the contents of a registry file into the Windows registry
11 description:
12 - Wraps the reg.exe command to import the contents of a registry file.
13 - Suitable for use with registry files created using M(ansible.windows.win_template).
14 - Windows registry files have a specific format and must be constructed correctly with carriage return and line feed line endings otherwise they will not
15 be merged.
16 - Exported registry files often start with a Byte Order Mark which must be removed if the file is to templated using M(ansible.windows.win_template).
17 - Registry file format is described at U(https://support.microsoft.com/en-us/kb/310516)
18 - See also M(ansible.windows.win_template), M(ansible.windows.win_regedit)
19 options:
20 path:
21 description:
22 - The full path including file name to the registry file on the remote machine to be merged
23 type: path
24 content:
25 description:
26 - When used instead of O(path), merges the value specified into the Windows registry. It must not include the Byte Order Mark.
27 type: str
28 version_added: 2.2.0
29 compare_to:
30 description:
31 - The parent key to use when comparing the contents of the registry to the contents of the file. Needs to be in HKLM or HKCU part of registry.
32 Use a PS-Drive style path for example HKLM:\SOFTWARE not HKEY_LOCAL_MACHINE\SOFTWARE
33 If not supplied, or the registry key is not found, no comparison will be made, and the module will report changed.
34 type: str
35 notes:
36 - Organise your registry files so that they contain a single root registry
37 key if you want to use the compare_to functionality.
38 - This module does not force registry settings to be in the state
39 described in the file. If registry settings have been modified externally
40 the module will merge the contents of the file but continue to report
41 differences on subsequent runs.
42 - To force registry change, use M(ansible.windows.win_regedit) with C(state=absent) before
43 using C(community.windows.win_regmerge).
44 seealso:
45 - module: ansible.windows.win_reg_stat
46 - module: ansible.windows.win_regedit
47 author:
48 - Jon Hawkesworth (@jhawkesworth)
49 '''
50
51 EXAMPLES = r'''
52 - name: Merge in a registry file without comparing to current registry
53 community.windows.win_regmerge:
54 path: C:\autodeploy\myCompany-settings.reg
55
56 - name: Compare and merge registry file
57 community.windows.win_regmerge:
58 path: C:\autodeploy\myCompany-settings.reg
59 compare_to: HKLM:\SOFTWARE\myCompany
60
61 - name: Merge in a registry file specified as content without comparing to current registry
62 community.windows.win_regmerge:
63 content: |
64 Windows Registry Editor Version 5.00
65
66 [HKEY_LOCAL_MACHINE\SOFTWARE\myCompany]
67 "ExampleKey"=dword:00000001
68
69 - name: Compare and merge registry file specified as content
70 community.windows.win_regmerge:
71 content: |
72 Windows Registry Editor Version 5.00
73
74 [HKEY_LOCAL_MACHINE\SOFTWARE\myCompany]
75 "ExampleKey"=dword:00000001
76 compare_to: HKLM:\SOFTWARE\myCompany
77 '''
78
79 RETURN = r'''
80 compare_to_key_found:
81 description: whether the parent registry key has been found for comparison
82 returned: when comparison key not found in registry
83 type: bool
84 sample: false
85 difference_count:
86 description: number of differences between the registry and the file
87 returned: changed
88 type: int
89 sample: 1
90 compared:
91 description: whether a comparison has taken place between the registry and the file
92 returned: when a comparison key has been supplied and comparison has been attempted
93 type: bool
94 sample: true
95 '''