8

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?

Andy Pah
  • 251
  • 2
  • 5
  • If you want to do this directly in VS Code, you can install this extension, which allows to encrypt/decrypt vault files in VS Code: https://marketplace.visualstudio.com/items?itemName=dhoeric.ansible-vault – nwinkler Aug 10 '18 at 12:33
  • 4
    Sadly it doesn't allow to edit. I always think decrypt should never be used over edit... – oliviercuyp Jan 29 '19 at 21:41

1 Answers1

17

Found it out. I need to:

EDITOR='code --wait' ansible-vault edit test.txt
Andy Pah
  • 251
  • 2
  • 5