مكتبة الشروحات

Using cloud-init for first-boot configuration طباعة

  • cloud-init, automation, boot, configuration
  • 0

Overview

cloud-init lets you automate a Pod's first boot: create users, install packages, write files and run commands. On ALYPOD you paste a cloud-init script during deployment or reinstall, and it runs automatically when the system comes up.

Before you begin

  • A Pod being deployed (or reinstalled) from the ALYPOD Console.
  • Basic YAML knowledge — indentation matters.
  • Any secrets you reference should be fine to store in the script (avoid plaintext passwords where possible; prefer SSH keys).

Steps

1. Write a cloud-init script

Paste this into the Cloud-init / User data field of the deploy wizard:

```yaml

cloud-config

packageupdate: true packageupgrade: true packages: - nginx - ufw users: - name: deploy groups: sudo shell: /bin/bash sudo: ALL=(ALL) NOPASSWD:ALL sshauthorizedkeys: - ssh-ed25519 AAAAC3... [email protected] write_files: - path: /etc/motd content: | Welcome to your ALYPOD Pod runcmd: - ufw allow OpenSSH - ufw allow 'Nginx Full' - ufw --force enable - systemctl enable --now nginx ```

The first line #cloud-config is required.

2. Deploy the Pod

Finish the deploy wizard. cloud-init runs on first boot and typically completes within a minute or two.

3. Verify it worked

```bash

Is cloud-init done?

cloud-init status --wait

Did our package install?

systemctl status nginx

Check the log for errors

sudo cat /var/log/cloud-init-output.log ```

Useful directives

  • package_update / package_upgrade — refresh and upgrade packages.
  • packages — install a list of packages.
  • users — create accounts with SSH keys and sudo.
  • write_files — drop config files.
  • runcmd — run shell commands last.

Troubleshooting

  • Problem: nothing ran. Solution: confirm the script starts with #cloud-config and uses spaces, not tabs.
  • Problem: a command failed. Solution: read /var/log/cloud-init-output.log for the exact error.
  • Problem: need to re-run. Solution: you can test manually with sudo cloud-init clean && sudo cloud-init init, but a clean reinstall is safest.

Related articles

  • [How to deploy a CPU Pod]
  • [Adding and managing SSH keys]
  • [Initial server hardening after installation]

هل كانت المقالة مفيدة ؟

« السابق