What am I doing wrong here?
$ ansible-vault encrypt_string --output ./example.yml --vault-password-file .vault_pass more
Encryption successful
$ ansible-vault view --vault-password-file .vault_pass example.yml
ERROR! input is not vault encrypted data. example.yml is not a vault encrypted file for example.yml
$ cat example.yml
!vault |
$ANSIBLE_VAULT;1.1;AES256
65366566626238336566363334613665653131636338643930643163643538396332376162393331
6537353466653333326537656264393737356561353665300a306536393733363339636261303866
65336637333965636231356437653935356139333864373237623033333466623938313865623539
3536366534636538660a303563666439623761363531313961363235343339623061333832316638
6530
when I remove !vault | from the file I'm able to view it
$ cat example.yml
$ANSIBLE_VAULT;1.1;AES256
65366566626238336566363334613665653131636338643930643163643538396332376162393331
6537353466653333326537656264393737356561353665300a306536393733363339636261303866
65336637333965636231356437653935356139333864373237623033333466623938313865623539
3536366534636538660a303563666439623761363531313961363235343339623061333832316638
6530
View the file
ansible-vault view --vault-password-file .vault_pass example.yml
more
I would expect to view the view without modification.
The output of
encrypt_stringis meant to be used as the value in an ansible variable file (akey: valuedictionary). That is, you would expect to see something like:You would use this in a playbook like:
We would run the playbook like this:
The
ansible-vault viewcommand is for viewing an encrypted file (that you create using theencryptcommand), rather than a single encrypted value in an otherwise plaintext file: