Security for Ansibles
Ansible security covers protecting secrets and controlling privileges. Ansible Vault encrypts variables or files so passwords and keys can live in version control, and privilege escalation with become lets tasks run as root or another user after connecting as an ordinary account.
Stage: Organisation · Part of the Ansible roadmap · Last reviewed 19 November 2026
What to learn in Security
- Encrypt a variables file with ansible-vault and edit it later
- Run a playbook supplying the vault password from a file or prompt
- Use become and become_user to run a task with elevated rights
- Explain why plain-text passwords should never appear in playbooks
- Apply no_log to a task that handles sensitive output
Security interview questions
What does Ansible Vault protect?
Vault encrypts data at rest using AES, so you can commit secrets such as passwords and API keys to Git safely. It protects files or individual variables in the repository. It does not hide values from output when a task runs, so you still need no_log for sensitive tasks.
What does become do?
become tells Ansible to escalate privileges after logging in, by default using sudo to become root. You can set become_user and become_method for other users or tools. It lets you connect with a normal account and elevate only for tasks that need it, such as installing packages.
Where Security fits in the Ansible roadmap
Security belongs to the Organisation stage (intermediate level). Reuse and scale.
Other units in this stage
Back to the full Ansible roadmap