ansible-vars 1.0.14__py3-none-any.whl → 1.0.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ansible_vars/cli.py CHANGED
@@ -178,8 +178,7 @@ The sync works as long as the command is running, after which the target root di
178
178
  ''',
179
179
  'cmd_get': '''
180
180
  Looks up the value of a key in a vault and displays it if it exists.
181
- If the key resolves to a leaf value, the value is recursively decrypted and displayed.
182
- For a list or dictionary, the full YAML code is printed, but child values are not automatically decrypted.
181
+ The value will be shown in (recursively) decrypted form.
183
182
 
184
183
  JSON mode formatting:
185
184
  - [ ... ] or { ... } for lists/dictionaries, "<value>" for strings, <value> for numbers
ansible_vars/py.typed ADDED
File without changes
ansible_vars/vault.py CHANGED
@@ -30,7 +30,7 @@ class EncryptedVar():
30
30
 
31
31
  def __init__(self, cipher: str, name: str | None = None) -> None:
32
32
  '''Initialize an encrypted variable with an optional variable name. The name is only used for internal representation.'''
33
- # Encrypted has to hold a string like '$ANSIBLE_VAULT;1.2;AES256;ramiio\n123456<...>' (the newline is important)
33
+ # Encrypted has to hold a string like '$ANSIBLE_VAULT;1.2;AES256;someid\n123456<...>' (the newline is important)
34
34
  self.cipher: str = cipher
35
35
  self.name: str | None = name
36
36
 
@@ -107,7 +107,7 @@ class Vault():
107
107
  Parses a vault's (potentially encrypted) contents. Automatically detects if the content is wholly encrypted.
108
108
  If no keyring is supplied, only plain vars and content are supported.
109
109
  '''
110
- # If no keyring is supplied, create an empty one which will raise an Error if we try to en-/decrypt anything
110
+ # If no keyring is supplied, create an empty one which will raise an error if we try to en-/decrypt anything
111
111
  self.keyring: VaultKeyring = keyring or VaultKeyring(keys=None, detect_available_keys=False)
112
112
  # Full vault encryption, may also contain single encrypted variables either way
113
113
  self.full_encryption: bool
@@ -3,6 +3,7 @@
3
3
  # Standard library imports
4
4
  import os, re
5
5
  from typing import Type, cast
6
+ from contextlib import chdir
6
7
 
7
8
  # External library imports
8
9
  import ansible.constants as Ansible
@@ -202,16 +203,12 @@ class VaultKeyring():
202
203
  # Load secrets for discovered vault IDs
203
204
  if not vault_ids:
204
205
  return []
205
- prev_dir: str = os.getcwd()
206
- try:
207
- # XXX Hacky, but loading a vault ID like 'vaultid@get-password.sh' will be resolved from CWD
208
- # Could possibly be avoided by splitting the detected vault IDs and transforming any right-hand paths
209
- os.chdir(pardir)
206
+ # XXX Hacky, but the right-hand path from loading a vault ID like 'vaultid@get-password.sh' will be resolved from CWD
207
+ # Could possibly be avoided by splitting the detected vault IDs and transforming any right-hand paths
208
+ with chdir(pardir):
210
209
  secrets: list[tuple[str | None, VaultSecret]] = \
211
210
  CLI.setup_vault_secrets(DataLoader(), vault_ids, auto_prompt=False, initialize_context=False) # type: ignore
212
211
  return list(map(VaultKey.from_ansible_secret, secrets))
213
- finally:
214
- os.chdir(prev_dir)
215
212
 
216
213
  def __repr__(self) -> str:
217
214
  return f"VaultKeyring({ ', '.join(map(lambda key: key.id, self.keys)) or 'no keys' })"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ansible-vars
3
- Version: 1.0.14
3
+ Version: 1.0.15
4
4
  Summary: Manage vaults and variable files for Ansible
5
5
  Project-URL: Homepage, https://github.com/xorwow/ansible-vars
6
6
  Project-URL: Issues, https://github.com/xorwow/ansible-vars/issues
@@ -219,7 +219,7 @@ Starts a daemon which mirrors the decrypted contents of one or multiple vault or
219
219
 
220
220
  #### get
221
221
 
222
- Displays the (optionally recursively decrypted) value of a specified key in a vault or variable file. Supports dictionary and list traversal, and JSON output.
222
+ Displays the (by default recursively decrypted) value of a specified key in a vault or variable file. Supports dictionary and list traversal, and JSON output.
223
223
 
224
224
  #### set, del (experimental)
225
225
 
@@ -269,7 +269,7 @@ Contains the classes `Vault` and `VaultFile`. A `Vault` is initialized using the
269
269
 
270
270
  The `VaultKey` class represents a single vault secret, comprised of an identifier and an `ansible.parsing.vault.VaultSecret`. Can be initialized using a plain passphrase instead of a `VaultSecret` as well.
271
271
 
272
- The `VaultKeyring` combines a collection of `VaultKey`s. It supports auto-detection of any secrets available in the present working directory using the `ansible.cli` module, appending them to the `<keyring>.keys` collection. While all keys are tried in order for decryption operations, only one key can be used for encrypting data. This key is usually the first key in the `<keyring>.keys` collection, unless explicitly specified otherwise using `<keyring>.default_encryption_key` or passing a key to the `<keyring>.encrypt()` method.
272
+ The `VaultKeyring` combines a collection of `VaultKey`s. It supports auto-detection of any secrets available in the present working directory (or a custom source) using the `ansible.cli` module, appending them to the `<keyring>.keys` collection. While all keys are tried in order for decryption operations, only one key can be used for encrypting data. This key is usually the first key in the `<keyring>.keys` collection, unless explicitly specified otherwise using `<keyring>.default_encryption_key` or passing a key to the `<keyring>.encrypt()` method.
273
273
 
274
274
  #### util module
275
275
 
@@ -0,0 +1,13 @@
1
+ ansible_vars/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ ansible_vars/cli.py,sha256=D2_gUY3u3EpeP4T76YTez9n9gUrBySPwFRyKcrW2auI,66339
3
+ ansible_vars/constants.py,sha256=VNr78qbzdJ0Vn0psbzjjQngNG3VbHhk6NXTz30VNUno,1622
4
+ ansible_vars/errors.py,sha256=6dzyksPKWira9O2-Ir3MIOwr4XjN9MSBiRp5e6siY6Q,1256
5
+ ansible_vars/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ ansible_vars/util.py,sha256=UwGPBT19pee7lBpWuBzLPAvcrHUBAn6i1MrJvzM9OQ4,21265
7
+ ansible_vars/vault.py,sha256=F8Eyn8ebduC3Cmst07280Bt7Wmy293ZRt9QrwshVVCA,47011
8
+ ansible_vars/vault_crypt.py,sha256=Hv_bBn6gazVAnfo-h2ufsg1qAdaPB_Lvpicjl-rR-r8,11818
9
+ ansible_vars-1.0.15.dist-info/METADATA,sha256=LAixHYmmBpn82kfAGuBR16Xt3FbRG6plmEI1o1y1vlk,21071
10
+ ansible_vars-1.0.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
11
+ ansible_vars-1.0.15.dist-info/entry_points.txt,sha256=RrhkEH0MbfRzflguVrfYfthsFC5V2fkFnizUG3uHMtQ,55
12
+ ansible_vars-1.0.15.dist-info/licenses/LICENSE,sha256=ocyJHLG5wD12qB4uam2pqWTHIJmzloiyNyTex6Q2DKo,1062
13
+ ansible_vars-1.0.15.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- ansible_vars/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- ansible_vars/cli.py,sha256=0RScnMrG__L5mXu_OmEgxB3x4lTJ1lAyowlOJvQNcrE,66476
3
- ansible_vars/constants.py,sha256=VNr78qbzdJ0Vn0psbzjjQngNG3VbHhk6NXTz30VNUno,1622
4
- ansible_vars/errors.py,sha256=6dzyksPKWira9O2-Ir3MIOwr4XjN9MSBiRp5e6siY6Q,1256
5
- ansible_vars/util.py,sha256=UwGPBT19pee7lBpWuBzLPAvcrHUBAn6i1MrJvzM9OQ4,21265
6
- ansible_vars/vault.py,sha256=aGTU_GmJLw0QGjBQiNlRE_E-rRMEVVbwdr8IV2U2duk,47011
7
- ansible_vars/vault_crypt.py,sha256=58CECQrjHSKubUGL38TLuYF9h8KmO2e70swRgkS-Rn0,11870
8
- ansible_vars-1.0.14.dist-info/METADATA,sha256=iGS5L6S7IQF8agJHlDDvL5NvAv3eFcjbBhS9XtkIogA,21050
9
- ansible_vars-1.0.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- ansible_vars-1.0.14.dist-info/entry_points.txt,sha256=RrhkEH0MbfRzflguVrfYfthsFC5V2fkFnizUG3uHMtQ,55
11
- ansible_vars-1.0.14.dist-info/licenses/LICENSE,sha256=ocyJHLG5wD12qB4uam2pqWTHIJmzloiyNyTex6Q2DKo,1062
12
- ansible_vars-1.0.14.dist-info/RECORD,,