Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrypt string with ansible-vault 2.3.0

I have been waiting for ansible 2.3 as it was going to introduce encrypt_string feature.

Unfortuately I'm not sure how can I read the encrypted string.

I did try decrypt_string, decrypt (the file), view (the file) and nothing works.

cat test.yml  --- test: !vault |      $ANSIBLE_VAULT;1.1;AES256      37366638363362303836383335623066343562666662386233306537333232396637346463376430      3664323265333036663736383837326263376637616466610a383430623562633235616531303861      66313432303063343230613665323930386138613334303839626131373033656463303736366166      6635346135636437360a313031376566303238303835353364313434363163343066363932346165      6136 

The error I'm geeting is ERROR! input is not vault encrypted data for test.yml

How can I decrypt the string so I know what it's value without the need to run the play?

like image 326
MMT Avatar asked Apr 18 '17 08:04

MMT


People also ask

How do you decrypt ansible vault strings?

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 you use the vault in ansible?

The ansible-vault create command is used to create the encrypted file. After typing this command, it will ask for a password and then ask where to put your content. To check that the file has been encrypted, use the cat command. The following command is used to create encrypted files with --vault id .

How do you pass an encrypted password in ansible?

You can use the ansible-vault encrypt_string command for this. You'll be prompted to insert and then confirm the vault password. You can then start inserting the string value that you wish to encrypt. Press ctrl-d to end input.

How do you bypass the vault password in ansible-playbook?

To enable this feature, a command line tool, ansible-vault is used to edit files, and a command line flag --ask-vault-pass or --vault-password-file is used. You can also modify your ansible. cfg file to specify the location of a password file or configure Ansible to always prompt for the password.


1 Answers

You can also do with plain ansible command for respective host/group/inventory combination, e.g.:

$ ansible my_server -m debug -a 'var=my_secret' my_server | SUCCESS => {     "my_secret": "373861663362363036363361663037373661353137303762" } 
like image 160
famousgarkin Avatar answered Sep 22 '22 00:09

famousgarkin