Debian Codegraph @

ansible_collections/community/sops/plugins/doc_fragments/sops.py

raw
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2020 Felix Fontein <[email protected]>
4 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
5 # SPDX-License-Identifier: GPL-3.0-or-later
6
7 from __future__ import (absolute_import, division, print_function)
8 __metaclass__ = type
9
10
11 class ModuleDocFragment(object):
12 DOCUMENTATION = r"""
13 requirements:
14 - A binary executable C(sops) (U(https://github.com/getsops/sops)) must exist either in E(PATH) or configured as O(sops_binary).
15 options:
16 sops_binary:
17 description:
18 - Path to the SOPS binary.
19 - By default uses C(sops).
20 type: path
21 version_added: 1.0.0
22 age_key:
23 description:
24 - One or more age private keys that can be used to decrypt encrypted files.
25 - Will be set as the E(SOPS_AGE_KEY) environment variable when calling SOPS.
26 - Requires SOPS 3.7.1+.
27 type: str
28 version_added: 1.4.0
29 age_keyfile:
30 description:
31 - The file containing the age private keys that SOPS can use to decrypt encrypted files.
32 - Will be set as the E(SOPS_AGE_KEY_FILE) environment variable when calling SOPS.
33 - By default, SOPS looks for C(sops/age/keys.txt) inside your user configuration directory.
34 - Requires SOPS 3.7.0+.
35 type: path
36 version_added: 1.4.0
37 age_key_cmd:
38 description:
39 - A command that SOPS will execute to obtain an age private key that SOPS can use to decrypt encrypted files.
40 - Will be set as the E(SOPS_AGE_KEY_CMD) environment variable when calling SOPS.
41 - Requires SOPS 3.10.0+.
42 - When running this command and when SOPS 3.12.0+ is used, SOPS will set the E(SOPS_AGE_RECIPIENT) variable
43 to the identity of the key it wants to use to decrypt.
44 type: str
45 version_added: 2.3.0
46 age_ssh_private_keyfile:
47 description:
48 - The file containing the SSH private key that SOPS can use to decrypt encrypted files.
49 - Will be set as the E(SOPS_AGE_SSH_PRIVATE_KEY_FILE) environment variable when calling SOPS.
50 - By default, SOPS looks for C(~/.ssh/id_ed25519) and falls back to C(~/.ssh/id_rsa).
51 - Requires SOPS 3.10.0+.
52 type: path
53 version_added: 1.4.0
54 age_ssh_private_key_cmd:
55 description:
56 - A command that SOPS will execute to obtain an SSH private key that SOPS can use to decrypt encrypted files.
57 - Will be set as the E(SOPS_AGE_SSH_PRIVATE_KEY_CMD) environment variable when calling SOPS.
58 - When running this command, SOPS will set the E(SOPS_AGE_RECIPIENT) variable to the identity of the key
59 it wants to use to decrypt.
60 - Requires SOPS 3.12.0+.
61 type: str
62 version_added: 2.3.0
63 aws_profile:
64 description:
65 - The AWS profile to use for requests to AWS.
66 - This corresponds to the SOPS C(--aws-profile) option.
67 type: str
68 version_added: 1.0.0
69 aws_access_key_id:
70 description:
71 - The AWS access key ID to use for requests to AWS.
72 - Sets the environment variable E(AWS_ACCESS_KEY_ID) for the SOPS call.
73 type: str
74 version_added: 1.0.0
75 aws_secret_access_key:
76 description:
77 - The AWS secret access key to use for requests to AWS.
78 - Sets the environment variable E(AWS_SECRET_ACCESS_KEY) for the SOPS call.
79 type: str
80 version_added: 1.0.0
81 aws_session_token:
82 description:
83 - The AWS session token to use for requests to AWS.
84 - Sets the environment variable E(AWS_SESSION_TOKEN) for the SOPS call.
85 type: str
86 version_added: 1.0.0
87 gcp_oauth_access_token:
88 description:
89 - Provide a Google Cloud OAauth token.
90 - Will be set as the E(GOOGLE_OAUTH_ACCESS_TOKEN) environment variable when calling SOPS.
91 - Requires SOPS 3.10.0+.
92 type: str
93 version_added: 3.2.0
94 gcp_kms_client_type:
95 description:
96 - Determine which client to use to communicate with Google Cloud Services.
97 - Will be set as the E(SOPS_GCP_KMS_CLIENT_TYPE) environment variable when calling SOPS.
98 - Requires SOPS 3.12.0+.
99 type: str
100 choices:
101 rest: Use REST client
102 grpc: Use gRPC client
103 version_added: 3.2.0
104 config_path:
105 description:
106 - Path to the SOPS configuration file.
107 - If not set, SOPS will recursively search for the config file starting at the file that is encrypted or decrypted.
108 - This corresponds to the SOPS C(--config) option.
109 type: path
110 version_added: 1.0.0
111 enable_local_keyservice:
112 description:
113 - Tell SOPS to use local key service.
114 - When set to V(false), this corresponds to the SOPS C(--enable-local-keyservice=false) option.
115 type: bool
116 default: true
117 version_added: 1.0.0
118 keyservice:
119 description:
120 - Specify key services to use next to the local one.
121 - A key service must be specified in the form C(protocol://address), for example C(tcp://myserver.com:5000).
122 - This corresponds to the SOPS C(--keyservice) option.
123 type: list
124 elements: str
125 version_added: 1.0.0
126 """
127
128 ANSIBLE_PLUGIN = r'''
129 options:
130 sops_binary:
131 type: str
132 '''
133
134 ANSIBLE_VARIABLES = r'''
135 options:
136 sops_binary:
137 vars:
138 - name: sops_binary
139 age_key:
140 vars:
141 - name: sops_age_key
142 age_keyfile:
143 vars:
144 - name: sops_age_keyfile
145 age_key_cmd:
146 vars:
147 - name: sops_age_key_cmd
148 age_ssh_private_keyfile:
149 vars:
150 - name: sops_age_ssh_private_keyfile
151 age_ssh_private_key_cmd:
152 vars:
153 - name: sops_age_ssh_private_key_cmd
154 aws_profile:
155 vars:
156 - name: sops_aws_profile
157 aws_access_key_id:
158 vars:
159 - name: sops_aws_access_key_id
160 aws_secret_access_key:
161 vars:
162 - name: sops_aws_secret_access_key
163 aws_session_token:
164 vars:
165 - name: sops_session_token
166 - name: sops_aws_session_token
167 version_added: 1.2.0
168 gcp_oauth_access_token:
169 vars:
170 - name: sops_gcp_oauth_access_token
171 gcp_kms_client_type:
172 vars:
173 - name: sops_gcp_kms_client_type
174 config_path:
175 vars:
176 - name: sops_config_path
177 enable_local_keyservice:
178 vars:
179 - name: sops_enable_local_keyservice
180 keyservice:
181 vars:
182 - name: sops_keyservice
183 '''
184
185 ANSIBLE_ENV = r'''
186 options:
187 sops_binary:
188 env:
189 - name: ANSIBLE_SOPS_BINARY
190 version_added: 1.2.0
191 age_key:
192 env:
193 - name: ANSIBLE_SOPS_AGE_KEY
194 age_keyfile:
195 env:
196 - name: ANSIBLE_SOPS_AGE_KEYFILE
197 age_key_cmd:
198 env:
199 - name: ANSIBLE_SOPS_AGE_KEY_CMD
200 age_ssh_private_keyfile:
201 env:
202 - name: ANSIBLE_SOPS_AGE_SSH_PRIVATE_KEYFILE
203 age_ssh_private_key_cmd:
204 env:
205 - name: ANSIBLE_SOPS_AGE_SSH_PRIVATE_KEY_CMD
206 aws_profile:
207 env:
208 - name: ANSIBLE_SOPS_AWS_PROFILE
209 version_added: 1.2.0
210 aws_access_key_id:
211 env:
212 - name: ANSIBLE_SOPS_AWS_ACCESS_KEY_ID
213 version_added: 1.2.0
214 aws_secret_access_key:
215 env:
216 - name: ANSIBLE_SOPS_AWS_SECRET_ACCESS_KEY
217 version_added: 1.2.0
218 aws_session_token:
219 env:
220 - name: ANSIBLE_SOPS_AWS_SESSION_TOKEN
221 version_added: 1.2.0
222 gcp_oauth_access_token:
223 env:
224 - name: ANSIBLE_SOPS_GCP_OAUTH_ACCESS_TOKEN
225 gcp_kms_client_type:
226 env:
227 - name: ANSIBLE_SOPS_GCP_KMS_CLIENT_TYPE
228 config_path:
229 env:
230 - name: ANSIBLE_SOPS_CONFIG_PATH
231 version_added: 1.2.0
232 enable_local_keyservice:
233 env:
234 - name: ANSIBLE_SOPS_ENABLE_LOCAL_KEYSERVICE
235 version_added: 1.2.0
236 keyservice:
237 env:
238 - name: ANSIBLE_SOPS_KEYSERVICE
239 version_added: 1.2.0
240 '''
241
242 ANSIBLE_INI = r'''
243 options:
244 sops_binary:
245 ini:
246 - section: community.sops
247 key: binary
248 version_added: 1.2.0
249 # We do not provide an INI key for
250 # age_key
251 # to make sure that secrets cannot be provided in ansible.ini. Use environment variables or another mechanism for that.
252 age_keyfile:
253 ini:
254 - section: community.sops
255 key: age_keyfile
256 age_key_cmd:
257 ini:
258 - section: community.sops
259 key: age_key_cmd
260 age_ssh_private_keyfile:
261 ini:
262 - section: community.sops
263 key: age_ssh_private_keyfile
264 age_ssh_private_key_cmd:
265 ini:
266 - section: community.sops
267 key: age_ssh_private_key_cmd
268 aws_profile:
269 ini:
270 - section: community.sops
271 key: aws_profile
272 version_added: 1.2.0
273 aws_access_key_id:
274 ini:
275 - section: community.sops
276 key: aws_access_key_id
277 version_added: 1.2.0
278 # We do not provide an INI key for
279 # aws_secret_access_key
280 # to make sure that secrets cannot be provided in ansible.ini. Use environment variables or another mechanism for that.
281 aws_session_token:
282 ini:
283 - section: community.sops
284 key: aws_session_token
285 version_added: 1.2.0
286 # We do not provide an INI key for
287 # gcp_oauth_access_token
288 # to make sure that secrets cannot be provided in ansible.ini. Use environment variables or another mechanism for that.
289 gcp_kms_client_type:
290 ini:
291 - section: community.sops
292 key: gcp_kms_client_type
293 config_path:
294 ini:
295 - section: community.sops
296 key: config_path
297 version_added: 1.2.0
298 enable_local_keyservice:
299 ini:
300 - section: community.sops
301 key: enable_local_keyservice
302 version_added: 1.2.0
303 keyservice:
304 ini:
305 - section: community.sops
306 key: keyservice
307 version_added: 1.2.0
308 '''
309
310 ENCRYPT_SPECIFIC = r'''
311 options:
312 age:
313 description:
314 - Age fingerprints to use.
315 - This corresponds to the SOPS C(--age) option.
316 type: list
317 elements: str
318 version_added: 1.4.0
319 kms:
320 description:
321 - List of KMS ARNs to use.
322 - This corresponds to the SOPS C(--kms) option.
323 type: list
324 elements: str
325 version_added: 1.0.0
326 gcp_kms:
327 description:
328 - GCP KMS resource IDs to use.
329 - This corresponds to the SOPS C(--gcp-kms) option.
330 type: list
331 elements: str
332 version_added: 1.0.0
333 azure_kv:
334 description:
335 - Azure Key Vault URLs to use.
336 - This corresponds to the SOPS C(--azure-kv) option.
337 type: list
338 elements: str
339 version_added: 1.0.0
340 hc_vault_transit:
341 description:
342 - HashiCorp Vault key URIs to use.
343 - For example, C(https://vault.example.org:8200/v1/transit/keys/dev).
344 - This corresponds to the SOPS C(--hc-vault-transit) option.
345 type: list
346 elements: str
347 version_added: 1.0.0
348 pgp:
349 description:
350 - PGP fingerprints to use.
351 - This corresponds to the SOPS C(--pgp) option.
352 type: list
353 elements: str
354 version_added: 1.0.0
355 huawei_cloud_kms:
356 description:
357 - HuaweiCloud KMS key IDs to use.
358 - This corresponds to the SOPS C(--hckms) option.
359 - Requires SOPS 3.12.0+.
360 type: list
361 elements: str
362 version_added: 3.2.0
363 unencrypted_suffix:
364 description:
365 - Override the unencrypted key suffix.
366 - This corresponds to the SOPS C(--unencrypted-suffix) option.
367 type: str
368 version_added: 1.0.0
369 encrypted_suffix:
370 description:
371 - Override the encrypted key suffix.
372 - When set to an empty string, all keys will be encrypted that are not explicitly
373 marked by O(unencrypted_suffix).
374 - This corresponds to the SOPS C(--encrypted-suffix) option.
375 type: str
376 version_added: 1.0.0
377 unencrypted_regex:
378 description:
379 - Set the unencrypted key suffix.
380 - When specified, only keys matching the regular expression will be left unencrypted.
381 - This corresponds to the SOPS C(--unencrypted-regex) option.
382 type: str
383 version_added: 1.0.0
384 encrypted_regex:
385 description:
386 - Set the encrypted key suffix.
387 - When specified, only keys matching the regular expression will be encrypted.
388 - This corresponds to the SOPS C(--encrypted-regex) option.
389 type: str
390 version_added: 1.0.0
391 encryption_context:
392 description:
393 - List of KMS encryption context pairs of format C(key:value).
394 - This corresponds to the SOPS C(--encryption-context) option.
395 type: list
396 elements: str
397 version_added: 1.0.0
398 shamir_secret_sharing_threshold:
399 description:
400 - The number of distinct keys required to retrieve the data key with
401 L(Shamir's Secret Sharing, https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing).
402 - If not set here and in the SOPS config file, will default to V(0).
403 - This corresponds to the SOPS C(--shamir-secret-sharing-threshold) option.
404 type: int
405 version_added: 1.0.0
406 '''