Answer Posted / Shahzad Alam
To store sensitive data such as passwords and API keys securely in your Ansible playbooks, you can use encrypted variables:n1. Create a vault password: Run the command `ansible-vault create <playbook_name>` to generate an encrypted file.n2. Add secret data to the vault file: Edit the created file and add sensitive information within vault-wrapped blocks, which look like this: ```n---!nvault | ansible-vaultnmysecret:n username: myusernamen password: mypasswordn```n3. Encrypt the file: Save and exit the vault file, then run `ansible-vault encrypt <playbook_name>` to encrypt it.n4. Use the encrypted playbook: When you run your Ansible commands, provide the vault password when prompted.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How can I set the path or any other environment variable for a task or entire playbook?
Explain the callback plugin in ansible?
What features does the ansible tower provide?
How do I configure a jump host to access servers that I have no direct access to?
What are the variables in ansible?
How to keep secret data in a playbook?
How do I disable cowsay?
Is ansible an open source tool?
How is ansible used in a continuous delivery pipeline? Explain.
Compare ansible with chef.
How can one interpolate variables or dynamic variable names?
How do I access a variable name programmatically?
How to keep secret data in playbook?
What is ansible?
Can you copy files recursively onto a target host? If yes, how?