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 in Ansible by Potter
42 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 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 by Sid

Related Questions In Ansible

0 votes
1 answer
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,520 points
68 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,520 points
176 views
0 votes
1 answer

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 13, 2018 in Ansible by DareDev
• 6,520 points
75 views
+13 votes
2 answers
0 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 in Ansible by Kavya
133 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,190 points
1,394 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.