tomoh1r / ansible-vault

This project aim to R/W an ansible-vault yaml file
GNU General Public License v3.0
54 stars 32 forks source link

Support for non YAML files #31

Closed orangepeelbeef closed 3 years ago

orangepeelbeef commented 4 years ago

I see another user has support for JSON files but what about just simple text files? We have encrypted configuration files for our deployments and they fail yaml parsing because they are not yaml files.

Traceback (most recent call last): File "/usr/bin/ansible-vault-rekey", line 11, in load_entry_point('ansible-vault-rekey==1.0.1', 'console_scripts', 'ansible-vault-rekey')() File "/usr/lib/python3.8/site-packages/click/core.py", line 829, in call return self.main(args, kwargs) File "/usr/lib/python3.8/site-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/usr/lib/python3.8/site-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/lib/python3.8/site-packages/click/core.py", line 610, in invoke return callback(args, **kwargs) File "/usr/lib/python3.8/site-packages/ansible_vault_rekey-1.0.1-py3.8.egg/ansible_vault_rekey/cli.py", line 99, in main rekey.decrypt_file(f['file'], password_file, newpath) File "/usr/lib/python3.8/site-packages/ansible_vault_rekey-1.0.1-py3.8.egg/ansible_vault_rekey/ansible_vault_rekey.py", line 138, in decrypt_file r = vault.load(f.read()) File "/usr/lib/python3.8/site-packages/ansible_vault-1.2.0-py3.8.egg/ansible_vault/api.py", line 62, in load File "/usr/lib/python3.8/site-packages/yaml/init.py", line 162, in safe_load return load(stream, SafeLoader) File "/usr/lib/python3.8/site-packages/yaml/init.py", line 114, in load return loader.get_single_data() File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 49, in get_single_data node = self.get_single_node() File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 39, in get_single_node if not self.check_event(StreamEndEvent): File "/usr/lib/python3.8/site-packages/yaml/parser.py", line 98, in check_event self.current_event = self.state() File "/usr/lib/python3.8/site-packages/yaml/parser.py", line 171, in parse_document_start raise ParserError(None, None, yaml.parser.ParserError: expected '', but found '' in "", line 3, column 1: $ldap_url = REDACTED

tomoh1r commented 3 years ago

https://github.com/tomoh1r/ansible-vault/wiki/sample#plaintext Please consider to use load_raw/dump_raw method.