Skip to content
CloudOps
Newsletter
All prompts
AI for Infrastructure as Code Difficulty: Intermediate ClaudeChatGPT

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.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week