ansible-vars 1.0.13__tar.gz → 1.0.15__tar.gz
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-1.0.13 → ansible_vars-1.0.15}/PKG-INFO +3 -3
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/README.md +2 -2
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/pyproject.toml +1 -1
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/src/ansible_vars/cli.py +1 -2
- ansible_vars-1.0.15/src/ansible_vars/py.typed +0 -0
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/src/ansible_vars/vault.py +2 -2
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/src/ansible_vars/vault_crypt.py +5 -8
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/.gitignore +0 -0
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/LICENSE +0 -0
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/src/ansible_vars/__init__.py +0 -0
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/src/ansible_vars/constants.py +0 -0
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/src/ansible_vars/errors.py +0 -0
- {ansible_vars-1.0.13 → ansible_vars-1.0.15}/src/ansible_vars/util.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ansible-vars
|
3
|
-
Version: 1.0.
|
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 (
|
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
|
|
@@ -197,7 +197,7 @@ Starts a daemon which mirrors the decrypted contents of one or multiple vault or
|
|
197
197
|
|
198
198
|
#### get
|
199
199
|
|
200
|
-
Displays the (
|
200
|
+
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.
|
201
201
|
|
202
202
|
#### set, del (experimental)
|
203
203
|
|
@@ -247,7 +247,7 @@ Contains the classes `Vault` and `VaultFile`. A `Vault` is initialized using the
|
|
247
247
|
|
248
248
|
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.
|
249
249
|
|
250
|
-
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.
|
250
|
+
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.
|
251
251
|
|
252
252
|
#### util module
|
253
253
|
|
@@ -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
|
-
|
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
|
File without changes
|
@@ -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;
|
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
|
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
|
-
|
206
|
-
|
207
|
-
|
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
|
-
CLI.setup_vault_secrets(DataLoader(), vault_ids, auto_prompt=False) # type: ignore
|
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' })"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|