Ansible - ansible-vault create command

The ansible-vault command can be used to perform a number of tasks.

Additionally, there are a couple command line options to be aware of.

 

The ansible-vault create command is used to create an encrypted file. In this example, foo.txt is created.

ansible-vault create foo.txt

 

You will be prompted to create a new vault password.

New Vault password:

 

Or, to avoid being prompted for the vault password, you could create a Vault Password file, and then use the --vault-password-file command line option (if you are going to use the same password for all of the ansible-vault commands) . . .

ansible-vault create --vault-password-file /usr/local/vault/.vault_password.txt foo.txt

 

Or the --vault-id command line option (if you want to use different passwords) 

ansible-vault create --vault-id test@/usr/local/ansible/vault/.vault_password.txt foo.txt

 

The file will open in your default editor. Let's say you enter string "Hello World" and save foo.txt. On a Linux system, foo.txt could have the following owner and permissions. In this example, only john.doe can read and write to foo.txt.

-rw-------. 1 john.doe john.doe  355 Mar 16 18:48 foo.txt

 

Attempting to view the file using the cat command will display something like this. The ansible-vault view command can be used to view the content of the file (foo.txt in this example).

$ANSIBLE_VAULT;1.1;AES256
66303833643731313633343266616162613965636161313534376563383639646463376630626635
3136316663626536303061333531303234616562323637330a373633393736393863373566623261
65643764336263613730666665663763383063386137383331386136366232666637626566653032
3933393061666138650a656238386665343838613833643435623932306539633138376533613039
6531

 

If the file was encrypted with a vault id, the vault id (test in this example) will be included.

$ANSIBLE_VAULT;1.1;AES256;test
66303833643731313633343266616162613965636161313534376563383639646463376630626635
3136316663626536303061333531303234616562323637330a373633393736393863373566623261
65643764336263613730666665663763383063386137383331386136366232666637626566653032
3933393061666138650a656238386665343838613833643435623932306539633138376533613039
6531


Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter faa0d in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |