ansible-vars 1.0.3__tar.gz → 1.0.5__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.3 → ansible_vars-1.0.5}/PKG-INFO +6 -1
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/README.md +5 -0
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/pyproject.toml +1 -1
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/src/ansible_vars/cli.py +9 -5
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/.gitignore +0 -0
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/LICENSE +0 -0
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/src/ansible_vars/__init__.py +0 -0
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/src/ansible_vars/constants.py +0 -0
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/src/ansible_vars/errors.py +0 -0
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/src/ansible_vars/util.py +0 -0
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/src/ansible_vars/vault.py +0 -0
- {ansible_vars-1.0.3 → ansible_vars-1.0.5}/src/ansible_vars/vault_crypt.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.5
|
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
|
@@ -204,6 +204,10 @@ Creates, updates, or deletes a key-value pair from a vault or variable file. Whe
|
|
204
204
|
|
205
205
|
### Environment variables
|
206
206
|
|
207
|
+
#### ANSIBLE_HOME
|
208
|
+
|
209
|
+
If this variable is set, the program will use its value as the working directory. When running the script from somewhere else, this way keys will be detected and paths will be resolved as if you were in your Ansible root directory.
|
210
|
+
|
207
211
|
#### AV_COLOR_MODE
|
208
212
|
|
209
213
|
Set the color mode as you would with `-C <mode>`.
|
@@ -264,6 +268,7 @@ When editing a file or creating a daemon, decrypted vaults are written to disk t
|
|
264
268
|
- Will ignore files which cannot be parsed as an Ansible YAML file.
|
265
269
|
- `file-daemon` command
|
266
270
|
- Changes to file metadata (permissions, ...) are not mirrored.
|
271
|
+
- `ansible-vars` cannot operate on files which are not (Jinja2) YAML dictionaries.
|
267
272
|
|
268
273
|
## Extension plans
|
269
274
|
|
@@ -182,6 +182,10 @@ Creates, updates, or deletes a key-value pair from a vault or variable file. Whe
|
|
182
182
|
|
183
183
|
### Environment variables
|
184
184
|
|
185
|
+
#### ANSIBLE_HOME
|
186
|
+
|
187
|
+
If this variable is set, the program will use its value as the working directory. When running the script from somewhere else, this way keys will be detected and paths will be resolved as if you were in your Ansible root directory.
|
188
|
+
|
185
189
|
#### AV_COLOR_MODE
|
186
190
|
|
187
191
|
Set the color mode as you would with `-C <mode>`.
|
@@ -242,6 +246,7 @@ When editing a file or creating a daemon, decrypted vaults are written to disk t
|
|
242
246
|
- Will ignore files which cannot be parsed as an Ansible YAML file.
|
243
247
|
- `file-daemon` command
|
244
248
|
- Changes to file metadata (permissions, ...) are not mirrored.
|
249
|
+
- `ansible-vars` cannot operate on files which are not (Jinja2) YAML dictionaries.
|
245
250
|
|
246
251
|
## Extension plans
|
247
252
|
|
@@ -29,6 +29,11 @@ from pygments.lexers.templates import YamlJinjaLexer
|
|
29
29
|
from pygments.formatter import Formatter
|
30
30
|
from pygments.formatters import TerminalFormatter, Terminal256Formatter, TerminalTrueColorFormatter
|
31
31
|
|
32
|
+
# If we need to change the working directory, we have to do it before loading the Ansible vault library
|
33
|
+
# Else, keys will not be detected correctly
|
34
|
+
ANSIBLE_HOME: str = os.environ.get('ANSIBLE_HOME', os.getcwd())
|
35
|
+
os.chdir(ANSIBLE_HOME)
|
36
|
+
|
32
37
|
# Internal module imports
|
33
38
|
from .vault import VaultFile, EncryptedVar, ProtoEncryptedVar
|
34
39
|
from .vault_crypt import VaultKey, VaultKeyring
|
@@ -190,7 +195,7 @@ Deletes a node from a vault if it exists.
|
|
190
195
|
}
|
191
196
|
|
192
197
|
DEFAULT_EDITOR: str = os.environ.get('EDITOR', 'notepad.exe' if os.name == 'nt' else 'vi')
|
193
|
-
DEFAULT_COLOR_MODE: str = os.environ.get('AV_COLOR_MODE', '256')
|
198
|
+
DEFAULT_COLOR_MODE: str = os.environ.get('AV_COLOR_MODE', '256' if os.isatty(os.pipe()[1]) else 'none')
|
194
199
|
DEFAULT_TEMP_DIR: str = os.environ.get('AV_TEMP_DIR', gettempdir())
|
195
200
|
DEFAULT_CREATE_PLAIN: bool = os.environ.get('AV_CREATE_PLAIN', 'no').lower() in [ 'yes', 'y', 'true', 't', '1' ]
|
196
201
|
|
@@ -616,11 +621,11 @@ if config.command in [ 'create', 'edit' ]:
|
|
616
621
|
new_plain_leaves: list[tuple[Hashable, ...]] = []
|
617
622
|
def _find_new_plain_vars(path: tuple[Hashable, ...], value: Any) -> Any:
|
618
623
|
if path != ( SENTINEL_KEY, ) and type(value) is not EncryptedVar:
|
619
|
-
if vault.get(path, default=Unset)
|
624
|
+
if vault.get(path, default=Unset) != value:
|
620
625
|
new_plain_leaves.append(path)
|
621
626
|
return value
|
622
627
|
vault._transform_leaves(new_vault._data, _find_new_plain_vars, tuple())
|
623
|
-
if new_plain_leaves:
|
628
|
+
if not new_vault.full_encryption and new_plain_leaves:
|
624
629
|
print(f"\n[!] The following plain vars have been added in this edit:", Color.MEH)
|
625
630
|
print('\n'.join([ f"- { format_key_path(path) }" for path in new_plain_leaves ]))
|
626
631
|
# Log changes
|
@@ -727,8 +732,7 @@ if config.command == 'convert':
|
|
727
732
|
vault.save()
|
728
733
|
print(f"Vault converted to { 'outer' if vault.full_encryption else 'inner' } encryption.", Color.GOOD)
|
729
734
|
if not vault.full_encryption:
|
730
|
-
print('
|
731
|
-
print_yaml(vault.as_editable(with_header=False))
|
735
|
+
print('Please check the vault to make sure all secrets have been encrypted', Color.MEH)
|
732
736
|
_convert()
|
733
737
|
|
734
738
|
# Grep command
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|