Open rmacian opened 6 years ago
I thought I was having a similar problem, but I solved installing the pre-release version (2.0.0b1)
pip3 install ansible-vault==2.0.0b1
Anyway, I let the failure happening with the 1.2.0 version below, but not sure if it's the same:
I am doing an initial test, and a password in str format, but then this happens:
File "/home/xxxxxx/.local/lib/python3.6/site-packages/ansible_vault/api.py", line 70, in dump return self.dump_raw(yaml_text, stream=stream) File "/home/xxxxxx/.local/lib/python3.6/site-packages/ansible_vault/api.py", line 56, in dump_raw stream.write(encrypted) TypeError: write() argument must be str, not bytes
My code snippet:
vault = Vault('testuser01')
data = "example-Insecure_p$$Wd"
vault.dump(data, open("tests/data/vault.yml", 'w'))
Screenshot from debugging:
I am very new to ansible-vault and need this feature. So what's the status of this ticket?
What's the status of this issue?
While we wait for the maintainer to acknowledge this *looks at watch* ...SIX YEAR old issue, maybe the following can be of use: https://newbit.ch/ansible-vault-encrypted-variables/
I successfully used the author's example code to add support for reading vault-strings in a Python tool I'm writing. Should be easy to modify for most people's needs.
Since ansible 2.4 you can encrypt strings in a yaml file. We moved our whole yaml files encrypted to encrypted strings and it looks that the module does not support this:
https://docs.ansible.com/ansible/2.4/vault.html#use-encrypt-string-to-create-encrypted-variables-to-embed-in-yaml