Encrypting few variables and embedding them in playbook

0 votes
I have a playbook to bring up ec2 instance. I have two variables, specifying my aws access key and secret key. I know I can use ansible vault and encrypt the playbook. But is there a way where I can only encrypt those two variables? I do not want to encrypt the entire playbook.
Mar 7, 2019 in Ansible by Camron
1,016 views

1 answer to this question.

0 votes

Hey @Camron, you can just encrypt those two variables using the encrypt_sctring. 

Ansible Vault allows you to encrypt only specific variables. You can use the ansible-vault encrypt_string command for this.

ansible-vault encrypt_string

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. Now you can assign this encrypted value to a string in the playbook.

You can also achieve the same thing in a single line.

ansible-vault encrypt_string 'string' --name 'variable_name'

and then use this variable in your playbook.

answered Mar 7, 2019 by Fez

Related Questions In Ansible

0 votes
1 answer

ansible playbook: using multiple variables in loops

Use an indexed hostname, and then define ...READ MORE

answered Jul 16, 2018 in Ansible by DareDev
• 6,890 points
18,980 views
0 votes
1 answer

Create directories and download files in Ansible using Ansible playbook

Hey @Yash,  you could either use file module ...READ MORE

answered Jan 24, 2019 in Ansible by Cerdin
5,930 views
0 votes
1 answer

Define variables in Ansible Playbook

Variable names should be letters, numbers, and ...READ MORE

answered Jan 24, 2019 in Ansible by Jinha
1,345 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,024 views
+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Role of subelement module in an Ansible playbook

Hey @Rahul thanks for a better question ...READ MORE

answered Jan 16, 2019 in Ansible by Emily
2,387 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