# How to use ansible-vault encrypt\_string

**URL:** <https://forum.ansible.com/t/how-to-use-ansible-vault-encrypt-string/27148>\
**Category:** Ansible Project\
**Created:** [March 29, 2018, 3:09pm UTC](https://forum.ansible.com/t/how-to-use-ansible-vault-encrypt-string/27148 "2018-03-29T15:09:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric\_landers](https://avatars.discourse-cdn.com/v4/letter/e/47e85d/32.png) [@eric\_landers](https://forum.ansible.com/u/eric_landers)\
**Post date:** [March 29, 2018, 3:09pm UTC](https://forum.ansible.com/t/how-to-use-ansible-vault-encrypt-string/27148/1 "2018-03-29T15:09:56Z")

</div>

I’m trying to encrypt a password to use in a playbook but I don’t understand what the parameters mean when running the encrypt string command.

Let’s say my password is Password!123

Do I run the command like this?

[root@server1 ~]$ ansible-vault encrypt\_string --vault-id topsecret.yaml ‘Password!123’ --name ‘Password!123’  
Password!123: !vault |  
$ANSIBLE\_VAULT;1.1;AES256  
31636462383335363735326162373334356662306565343666623437356662326263376334626435  
3930336636343032303933326664623434306331396261390a383730353565303033366238643630  
38326663323636633265383531396230623238306239323365366237393731316130346132386434  
3738386364393966660a353663373936366637626632616166383139373933343962323466353265  
6265

**Then place this in the playbook?**

- name: show version  
hosts: bigip1  
connection: local

tasks:

- name: show version  
bigip\_command:  
commands:
- show sys version
- show sys clock  
server: “{{ inventory\_hostname }}”  
password: !vault |  
$ANSIBLE\_VAULT;1.1;AES256  
31636462383335363735326162373334356662306565343666623437356662326263376334626435  
3930336636343032303933326664623434306331396261390a383730353565303033366238643630  
38326663323636633265383531396230623238306239323365366237393731316130346132386434  
3738386364393966660a353663373936366637626632616166383139373933343962323466353265  
6265  
user: “admin”  
validate\_certs: “no”

When I try this I receive a FAILED! =\> {“msg”: “Attempting to decrypt but no vault secrets found”} error.

Thanks,

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 30, 2018, 9:03am UTC](https://forum.ansible.com/t/how-to-use-ansible-vault-encrypt-string/27148/2 "2018-03-30T09:03:11Z")

</div>

You need to provide the password file so Ansible can encrypt the vault string.  
&nbsp;&nbsp;--vault-id topsecret.yaml
