Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2020, Brian Scholer <@briantist>
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_psscript_info
10 short_description: Gather information about installed PowerShell Scripts
11 description:
12 - Gather information about PowerShell Scripts installed via PowerShellGet.
13 options:
14 name:
15 description:
16 - The name of the script.
17 - Supports any wildcard pattern supported by C(Get-InstalledScript).
18 - If omitted then all scripts will returned.
19 type: str
20 default: '*'
21 repository:
22 description:
23 - The name of the PSRepository the scripts were installed from.
24 - This acts as a filter against the scripts that would be returned based on the I(name) option.
25 - Only scripts installed from a registered repository will be returned.
26 - If the repository was re-registered after script installation with a new C(SourceLocation), this will not match.
27 type: str
28 requirements:
29 - C(PowerShellGet) module
30 seealso:
31 - module: community.windows.win_psrepository_info
32 - module: community.windows.win_psmodule_info
33 author:
34 - Brian Scholer (@briantist)
35 '''
36
37 EXAMPLES = r'''
38 - name: Get info about all script on the system
39 community.windows.win_psscript_info:
40
41 - name: Get info about the Test-RPC script
42 community.windows.win_psscript_info:
43 name: Test-RPC
44
45 - name: Get info about test scripts
46 community.windows.win_psscript_info:
47 name: Test*
48
49 - name: Get info about all scripts installed from the PSGallery repository
50 community.windows.win_psscript_info:
51 repository: PSGallery
52 register: gallery_scripts
53
54 - name: Update all scripts retrieved from above example
55 community.windows.win_psscript:
56 name: "{{ item }}"
57 state: latest
58 loop: "{{ gallery_scripts.scripts | map(attribute=name) }}"
59
60 - name: Get info about all scripts on the system
61 community.windows.win_psscript_info:
62 register: all_scripts
63
64 - name: Find scripts installed from a repository that isn't registered now
65 set_fact:
66 missing_repository_scripts: "{{
67 all_scripts
68 | json_query('scripts[?repository!=null && repository==repository_source_location].{name: name, version: version, repository: repository}')
69 | list
70 }}"
71
72 - debug:
73 var: missing_repository_scripts
74 '''
75
76 RETURN = r'''
77 scripts:
78 description:
79 - A list of installed scripts (or an empty list is there are none).
80 returned: always
81 type: list
82 elements: dict
83 contains:
84 name:
85 description:
86 - The name of the script.
87 type: str
88 sample: Test-RPC
89 version:
90 description:
91 - The script version.
92 type: str
93 sample: 1.2.3
94 installed_location:
95 description:
96 - The path where the script is installed.
97 type: str
98 sample: 'C:\Program Files\WindowsPowerShell\Scripts'
99 author:
100 description:
101 - The author of the script.
102 type: str
103 sample: Ryan Ries
104 copyright:
105 description:
106 - The copyright of the script.
107 type: str
108 sample: 'Jordan Borean 2017'
109 company_name:
110 description:
111 - The company name of the script.
112 type: str
113 sample: Microsoft Corporation
114 description:
115 description:
116 - The description of the script.
117 type: str
118 sample: This scripts tests network connectivity.
119 dependencies:
120 description:
121 - The script's dependencies.
122 type: list
123 elements: str
124 icon_uri:
125 description:
126 - The address of the icon of the script.
127 type: str
128 sample: 'https://raw.githubusercontent.com/scripter/script/main/logo.png'
129 license_uri:
130 description:
131 - The address of the license for the script.
132 type: str
133 sample: 'https://raw.githubusercontent.com/scripter/script/main/LICENSE'
134 project_uri:
135 description:
136 - The address of the script's project.
137 type: str
138 sample: 'https://github.com/scripter/script'
139 repository_source_location:
140 description:
141 - The source location of the repository where the script was installed from.
142 type: str
143 sample: 'https://www.powershellgallery.com/api/v2'
144 repository:
145 description:
146 - The PSRepository where the script was installed from.
147 - This value is not historical. It depends on the PSRepositories that are registered now for the current user.
148 - The C(repository_source_location) must match the current source location of a registered repository to get a repository name.
149 - If there is no match, then this value will match C(repository_source_location).
150 type: str
151 sample: PSGallery
152 release_notes:
153 description:
154 - The script's release notes. This is a free text field and no specific format should be assumed.
155 type: str
156 sample: |
157 ## 1.5.5
158 - Add optional param for detailed info
159
160 ## 1.4.7
161 - Bug fix for deadlock when getting parameters in an event
162
163 ## 1.1.4
164 - Bug fix when installing package from private feeds
165 installed_date:
166 description:
167 - The date the script was installed.
168 type: str
169 sample: '2018-02-14T17:55:34.9620740-05:00'
170 published_date:
171 description:
172 - The date the script was published.
173 type: str
174 sample: '2017-03-15T04:18:09.0000000'
175 updated_date:
176 description:
177 - The date the script was last updated.
178 type: str
179 sample: '2019-12-31T09:20:02.0000000'
180 package_management_provider:
181 description:
182 - This is the PowerShellGet package management provider used to install the script.
183 type: str
184 sample: NuGet
185 tags:
186 description:
187 - The tags defined in the script's C(AdditionalMetadata).
188 type: list
189 elements: str
190 sample:
191 - networking
192 - serialization
193 - git
194 - dsc
195 power_shell_get_format_version:
196 description:
197 - The version of the PowerShellGet specification format.
198 type: str
199 sample: '2.0'
200 additional_metadata:
201 description:
202 - Additional metadata included with the script or during publishing of the script.
203 - Many of the fields here are surfaced at the top level with some standardization. The values here may differ slightly as a result.
204 - The field names here vary widely in case, and are not normalized or converted to snake_case.
205 type: dict
206 '''