Interview Prep/Ansible/Variables, Facts and Templates

You need to pull a secret from AWS Secrets Manager at run time rather than keep it in Git.

AdvancedScenarioVariables, Facts and Templates
Answer

Situation read → Dynamic secret lookup.

What I'd do →

db_password: "{{ lookup('amazon.aws.secretsmanager_secret', 'prod/db/password', region='ap-south-1') }}"

Mark consuming tasks no_log: true, and give the controller an IAM role with secretsmanager:GetSecretValue on that ARN only.

Why → Lookups run on the controller, so targets never need AWS permissions.

Interview tip → Compare with Vault (file-based), HashiCorp Vault lookup and AWX credential injection.

All Ansible questions Roadmap: Ansible

More on Variables, Facts and Templates