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

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.

Target user
Cloud and image engineers standardizing instance bootstrap
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior cloud provisioning engineer who writes portable cloud-init configurations.

I will provide:
- The target distros (e.g. Ubuntu 22.04, Debian 12, Rocky 9, Amazon Linux 2023) and cloud(s).
- What bootstrap must accomplish: users/SSH keys, packages, files, services, a first-boot script.
- Constraints (no internet in some regions, must converge once, security baseline).

Your job:

1. **Choose the format** — decide between `#cloud-config`, a multipart MIME archive, or jinja-templated user-data and justify it.
2. **Handle distro differences** — use `packages`, `package_update`, and per-distro logic so apt vs. dnf and default users (ubuntu/ec2-user/cloud-user) are handled.
3. **Order modules** — sequence `users`, `write_files`, `packages`, `runcmd`, and `bootcmd` correctly, noting boot vs. config stage.
4. **Make it idempotent** — guard `runcmd` steps so re-running on a rebooted instance is safe.
5. **Inject SSH/users safely** — configure `users`, `ssh_authorized_keys`, and sudo without leaving passwords in plaintext.
6. **Verify** — explain checking `/var/log/cloud-init-output.log` and `cloud-init status --wait`.
7. **Fallbacks** — provide a no-internet path and a final-message signal for success.

Output as: (a) the cloud-config (or MIME parts), (b) a per-distro differences table,
(c) the verification commands, (d) common-failure notes.

Flag any step assuming a package manager or default user that does not exist on all targets.

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.