Search code examples
ansibleyamlansible-vault

Store encrypted Ansible Vault string as a single line


this might be an Ansible related question or YAML one.

In my Ansible variables I have some encrypted strings:

---

env_passphrase: !vault |
  $ANSIBLE_VAULT;1.2;AES256;staging
  63623836336639643662326138326337353835623233386666303035333937653135313234633535
  3732303062313431613761323538313739323864336465620a653633376634353030343737363439
  39323361396630346332373139326162346230623035363535393233643764376239363136343332
  6165383765613135320a663365346434316335326365646634373632313332306235653561363565
  3732

Would it be possible to have all the encrypted content on the same line where the key lies?

Something like below would work?

---

env_passphrase: !vault $ANSIBLE_VAULT;1.2;AES256;collaudo 636238363366396436623261383263373538356232333866663030353339376531353132346335353732303062313431613761323538313739323864336465620a653633376634353030343737363439393233613966303463323731393261623462306230353635353932336437643762393631363433326165383765613135320a6633653464343163353263656466343736323133323062356535613635653732

Solution

  • This one will do the trick :)

    ---
    env_passphrase: !vault "$ANSIBLE_VAULT;1.1;AES256\r\n636238363366396436623261383..."