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 in Ansible by Camron
47 views

1 answer 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 @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 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,520 points
2,732 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 in Ansible by Cerdin
185 views
0 votes
1 answer

Define variables in Ansible Playbook

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

answered Jan 24 in Ansible by Jinha
31 views
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 6,480 points
211 views
+13 votes
2 answers
0 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 in Ansible by Emily
53 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.