Encrypt a single variable using ansible Vault

0 votes
I know I can encrypt an entire file using Ansible Vault but what if I want to encrypt a single variable? How do encrypt that?
Jan 29, 2019 in Ansible by Potter
2,662 views

2 answers to this question.

0 votes

Hey @Potter, you could do something like this, it's the most basic way of encrypting a single variable:

ansible-vault encrypt_string 
> New Vault password: 
> Confirm New Vault password: 
> Reading plaintext input from stdin. (ctrl-d to end input) 
> this is a plaintext string 
> !vault | 
> $ANSIBLE_VAULT;1.1;AES256 
> 39393766663761653337386436636466396531353261383237613531356531343930663133623839 
> 3436613834303264613038623432303837393261663233640a363633343337623065613166306363 
> 37336132363462386138343535346264333061656134636631326164643035313433393831616131 
> 3635613565373939310a316132313764356432333366396533663965333162336538663432323334 
> 33656365303733303664353961363563313236396262313739343461383036333561 
> Encryption successful
answered Jan 29, 2019 by Zunaid
0 votes

Adding to @Zunaid's answer, this can also be done in a single line:

ansible-vault encrypt_string 'this is a plaintext string' --name 'some_string' 
> New Vault password:
> Confirm New Vault password: 
> some_string: !vault | 
> $ANSIBLE_VAULT;1.1;AES256
answered Jan 29, 2019 by Sid

Related Questions In Ansible

0 votes
1 answer

How to create a new encrpted file using Ansible Vault?

If you are creating a new file ...READ MORE

answered Jan 29, 2019 in Ansible by Kyraa
1,054 views
0 votes
1 answer

How can I create a new user using ansible ploybook?

You're switching from the root user. Root ...READ MORE

answered Mar 29, 2018 in Ansible by DareDev
• 6,890 points
914 views
0 votes
1 answer

Using multiple config files using same template in a role in ansible

Go through this include_role module: tasks: - ...READ MORE

answered Jun 5, 2018 in Ansible by DareDev
• 6,890 points
4,237 views
+1 vote
2 answers

Running ansible command on a single server when it is deployed to multiple servers

You can try the run_once attribute: Example from ...READ MORE

answered Jun 14, 2018 in Ansible by DareDev
• 6,890 points
2,475 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,053 views
+2 votes
1 answer
0 votes
1 answer

How to encrypt and existing file using Ansible Vault?

Hey @Kyraa, to encrypt an existing file ...READ MORE

answered Jan 29, 2019 in Ansible by Kavya
3,464 views
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,240 points
14,725 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP