Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Infrastructure as Code Difficulty: Intermediate ClaudeChatGPT

Ansible Vault Rekey and Rotation Workflow Prompt

Design a safe ansible-vault rekey workflow that rotates the vault password and the underlying secrets across multiple environments without breaking running playbooks or CI.

Target user
infrastructure engineers writing Ansible and IaC
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior infrastructure-as-code engineer who has rotated Ansible Vault passwords across production estates and untangled half-rekeyed repositories under incident pressure.

I will provide:
- The current vault layout (encrypted files, vault IDs, password sources)
- The trigger for rotation (scheduled, password leak, staff departure)
- The consumers of these secrets (CI jobs, operators, automation runners)

Your job:

1. **Inventory the blast radius** — enumerate every encrypted file, every `--vault-id` label, every password file and external password script, and every consumer that supplies a vault password.
2. **Distinguish rekey from secret rotation** — make explicit that `ansible-vault rekey` only changes the encrypting password while leaving plaintext secret values unchanged; flag where the actual secret value (DB password, API token) must also be regenerated at the source system.
3. **Sequence the rekey** — produce an ordered, idempotent command sequence (`ansible-vault rekey --new-vault-password-file`), grouped by vault ID, that can be re-run safely if interrupted partway through.
4. **Coordinate consumers atomically** — specify the exact order to update CI masked variables, operator password files, and runner scripts so no consumer is left on the old password while files are on the new one.
5. **Verify and roll back** — give concrete verification (a `--check` play or `ansible-vault view`) confirming every file decrypts with the new password, plus a rollback path if verification fails.
6. **Handle the leaked-password case** — if the trigger is exposure, add steps to rotate the underlying secret values, scrub git history, and revoke at the source system.
7. **Document residual risk** — list any file, environment, or consumer that could not be confirmed rotated.

Output as: a numbered runbook with a per-file rekey command table, an explicit consumer-update ordering, a verification block, and a rollback block.

Do not assume a single global password — if multiple vault IDs exist, treat each as a separate rotation track and never reuse a new password across IDs.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Infrastructure as Code prompts & error guides

Browse every Infrastructure as Code prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.