Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I edit ansible-vault encrypted files in visual-studio-code?

I am using the command line tool ansible-vault and try to edit an encrypted file.

EDITOR=code ansible-vault edit test.txt

It is expected that code opens with the decrypted content in the editor. After saving ansible-vault should decrypt the (changed) buffer. Works much like editing a git commit message.

However, the buffer is empty. And changing/saving doesn't do much to the file.

I also tried it with vim and subl, which both worked as expected. What do I have to do to use visual-studio-code for the task?

like image 303
Andy Pah Avatar asked Mar 04 '18 22:03

Andy Pah


People also ask

How do I edit an ansible-vault file?

When you need to edit an encrypted file, use the ansible-vault edit command: ansible-vault edit vault. yml.

Which ansible command is used to edit the content of encrypted files?

To enable this feature, a command line tool - ansible-vault - is used to edit files, and a command line flag ( --ask-vault-pass , --vault-password-file or --vault-id ) is used.

How do I decrypt ansible-vault files?

If you have an encrypted file that you no longer want to keep encrypted, you can permanently decrypt it by running the ansible-vault decrypt command. This command will save the file unencrypted to the disk, so be sure you do not want to edit it instead.

How do I decrypt files in Visual Studio?

To decrypt open the command prompt and type “Decrypt”.


1 Answers

Found it out. I need to:

EDITOR='code --wait' ansible-vault edit test.txt
like image 160
Andy Pah Avatar answered Oct 08 '22 22:10

Andy Pah