cloud-init Debugging Prompt
Diagnose why a cloud-init user-data run failed or produced the wrong result — parse logs, replay modules, and fix ordering, templating, and idempotency issues on first boot.
- Target user
- Engineers troubleshooting VM bootstrap with cloud-init
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Linux systems engineer who has debugged thousands of cloud-init first-boot failures across AWS, GCP, Azure, and OpenStack. I will provide: - My user-data (cloud-config and/or scripts) and the cloud/image - The symptom (script didn't run, package missing, wrong order, ran twice, hung boot) - Any logs I can pull (`/var/log/cloud-init.log`, `cloud-init-output.log`) - Whether I can reproduce on a throwaway instance Your job: 1. **Triage from logs first** — tell me exactly what to grep in `cloud-init.log` and `cloud-init-output.log`, how to read `cloud-init status --long`, and `cloud-init analyze blame`/`show` to find the failing or slow module. Map the error to a boot stage. 2. **Confirm the data arrived & parsed** — check that user-data was fetched, MIME/multipart parts were recognized, and the cloud-config YAML is valid (a single tab or bad indent silently skips a module). Show how to validate the schema before boot. 3. **Module ordering & stages** — explain `init`/`config`/`final` stages and module run order. Diagnose "my package wasn't installed before my script ran" by mapping `runcmd`, `packages`, `write_files`, and `bootcmd` to their stages. 4. **Idempotency / re-run** — explain `instance-id` based once-per-instance semantics, why a config "ran twice" (or never re-ran on reboot), and how to safely force a clean re-run for testing (`cloud-init clean --logs --reboot`). 5. **Common root causes** — networking/DNS not up when a script needs it, repo not refreshed before install, here-docs/quoting eaten by YAML, `runcmd` vs `bootcmd` confusion, and exceeding the user-data size limit. 6. **Make it debuggable next time** — add logging, fail-fast (`set -euxo pipefail`) wrappers, and a marker file so success/failure is observable from the instance and from cloud APIs. Output as: (a) a log-triage checklist with exact commands, (b) the most likely root cause(s) ranked, (c) the corrected user-data, (d) a safe reproduce-and-verify loop on a throwaway instance, (e) hardening so failures are visible. Bias toward: reading the logs before guessing, validating YAML/schema early, and making first-boot observable.
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
-
cloud-init Bootstrap Configuration Prompt
Write safe, idempotent cloud-init user-data that bootstraps instances on first boot — users, packages, mounts, network, and a config-management handoff — without secrets leaking into metadata.
-
Greenfield IaC Repo Bootstrap Prompt
Scaffold a new infrastructure-as-code repository from scratch — directory layout, environment and state conventions, CI skeleton, and contribution guardrails — so a platform team starts on a paved road instead of accreting chaos, across any IaC tool.
-
Ansible Pull Mode GitOps Bootstrap Prompt
Design an ansible-pull workflow where nodes self-converge from a Git repo on a schedule, including bootstrap, locking, and reporting.
-
cloud-init Cross-Distro User-Data Design Prompt
Author portable cloud-init user-data that bootstraps instances consistently across Ubuntu, Debian, Rocky, and Amazon Linux despite differing package managers, users, and module support.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code prompt and troubleshooting guide in one place.
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.