Safeguard
Security Guides•

How do Ansible vault IDs keep dev and production secrets separate?

Vault IDs label encrypted content so dev and production use different passwords. How to set them up, what the label reveals, and where to store passwords.

Safeguard Security Team
3 min read

Use a vault ID to label content with the password that encrypted it, so development and production secrets use different passwords. The label is stored in plain text in the file header, and you pass --vault-id label@source at run time to choose which password to use.

One password or many

A vault password can be any string you choose. With a small team and few secrets, one password for everything is simple, but it must be stored securely in a file or secret manager. With a larger team or many values, the documentation suggests multiple passwords, for example per user, per access level, per file, per directory or per environment.

How vault IDs work

You pass the ID in three places:

  1. With --vault-id to ansible-vault when you create encrypted content.
  2. With the same ID wherever you store the password.
  3. With --vault-id to ansible-playbook when you run a playbook that uses that content.

The encrypted variable carries the label in its header. A header looks like $ANSIBLE_VAULT;1.2;AES256;dev, with the label as the last element before the encrypted data. The label is a hint, in plain text.

Example

ansible-vault encrypt_string --vault-id dev@prompt 'dbpass' --name db_password
ansible-playbook site.yml --vault-id dev@prompt --vault-id prod@~/.vault_prod

The source after the @ can be a prompt, a file or a script.

What this gives you

BenefitDetail
Blast radiusSomeone with the dev password cannot open production content
AuditabilityThe label shows which password a file expects
Separate rotationRotate prod without touching dev

What to watch

  • Because the label is plain text, do not put sensitive words in it. Use prod, not a customer name.
  • A password script is code, so review it like code.
  • Do not commit password files. Keep them outside the repository, with tight permissions.
  • Use a secret manager as the password source in CI where you can.

Rollout steps

  1. Choose labels that match your environments.
  2. Re-encrypt production secrets under a separate password.
  3. Store each password in a different secret entry with its own access list.
  4. Pass only the IDs a job needs, so a dev pipeline never receives the prod password.
  5. Rotate when people leave a team.

Quick check

Is the vault ID label encrypted?

No. It is in the header in plain text.

Do I need vault IDs with one password?

No. They are for telling several passwords apart.

Can a playbook use several passwords at once?

Yes, by passing several --vault-id options.

Safeguard offers SBOM and dependency scanning and policy gates that can block a pull request on findings, and you can try a free scan at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.