ansible-vars 1.0.4__py3-none-any.whl → 1.0.5__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
@@ -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
 
@@ -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('New vault contents:\n')
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ansible-vars
3
- Version: 1.0.4
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
 
@@ -1,12 +1,12 @@
1
1
  ansible_vars/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- ansible_vars/cli.py,sha256=O3DELnEBaRyNyqFTA_jBP-Rafq_fH47chO085DZWU-Y,58778
2
+ ansible_vars/cli.py,sha256=oko3OotkmPf_XEPZkzfcqZfT_-NArCBtL_VTEzXi7As,59049
3
3
  ansible_vars/constants.py,sha256=Nd3sIuSoOvyfUfHfnsnJBDGMW7eNzbMm1NAvEQio9hE,1624
4
4
  ansible_vars/errors.py,sha256=VnViEBMR3rIeioMj460DgdBA5S5FYiDObaDDhG2FMBs,857
5
5
  ansible_vars/util.py,sha256=BzS7n3UzaKqVZ3W78HVkJtdVCYofprqQDtU8wYH1d0Q,21325
6
6
  ansible_vars/vault.py,sha256=_dp1K5_UAFGgcg6iO4on4-L_BaJO2cHP6My3EU6enA4,45593
7
7
  ansible_vars/vault_crypt.py,sha256=JcFc6dTZ6EqhKXv_C5ofggTpBK8hWG3ZwrBrDNYcEIg,9501
8
- ansible_vars-1.0.4.dist-info/METADATA,sha256=T8ZAx8InOTtaMSGnw74znzAUdCzUkSP9FcmGk9bc1nc,16863
9
- ansible_vars-1.0.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- ansible_vars-1.0.4.dist-info/entry_points.txt,sha256=RrhkEH0MbfRzflguVrfYfthsFC5V2fkFnizUG3uHMtQ,55
11
- ansible_vars-1.0.4.dist-info/licenses/LICENSE,sha256=ocyJHLG5wD12qB4uam2pqWTHIJmzloiyNyTex6Q2DKo,1062
12
- ansible_vars-1.0.4.dist-info/RECORD,,
8
+ ansible_vars-1.0.5.dist-info/METADATA,sha256=cAMDxt2dxD4IybRvv66fKiUhfV-DqQevcJ_eKTRPlk4,17198
9
+ ansible_vars-1.0.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ ansible_vars-1.0.5.dist-info/entry_points.txt,sha256=RrhkEH0MbfRzflguVrfYfthsFC5V2fkFnizUG3uHMtQ,55
11
+ ansible_vars-1.0.5.dist-info/licenses/LICENSE,sha256=ocyJHLG5wD12qB4uam2pqWTHIJmzloiyNyTex6Q2DKo,1062
12
+ ansible_vars-1.0.5.dist-info/RECORD,,