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
58 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 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,810 points
3,602 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
379 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
42 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,870 points
489 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
84 views