Cloud-init scripts

A cloud-init script configures a new cloud server during its first startup. Coolify can send one as provider user data when creating a Hetzner, DigitalOcean, or Vultr server.

Use a script to perform repeatable initialization such as creating files, installing packages, or applying operating-system settings before Coolify validates the server.

Test scripts before production use

A broken cloud-init script can leave a new server incomplete or unreachable. Test with a temporary server and avoid changing the SSH access Coolify requires.

Only team administrators and owners can create, update, or delete cloud-init scripts. Scripts belong to the active team.

Create a reusable script

Open Cloud-Init Scripts

Open Keys & Tokens in the Coolify sidebar, then select Cloud-Init Scripts.

Add the script

  1. Select + Add.
  2. Enter a descriptive Script Name.
  3. Enter the cloud-config YAML under Script Content.
  4. Select Create Script.

The name and script content are required. Coolify validates that the content is valid cloud-init YAML before saving it.

For example:

#cloud-config
package_update: true
packages:
  - curl

write_files:
  - path: /etc/motd
    content: |
      Managed by Coolify

Cloud-init features vary by Linux image and provider. Check the image's cloud-init support before relying on a module.


Use a script while provisioning

  1. Open Servers and select + Add.
  2. Choose Hetzner, DigitalOcean, or Vultr.
  3. Complete the provider's server settings.
  4. Open the advanced options.
  5. Select the saved cloud-init script.
  6. Review the remaining options, then select Buy & Create Server.

You can also enter a script directly in the provisioning form. Enable Save this script for later use if it should be added to the team's reusable scripts.

The script is sent only when the provider creates the server. It does not run when you validate a server or add an existing server manually.

Saved scripts are templates

Editing a saved script changes future provisioning requests that use it. It does not rerun cloud-init or modify servers that were already created.


Edit or delete a script

Open Keys & Tokens > Cloud-Init Scripts, then select a script.

  • Change Script Name or Script Content, then select Save.
  • Select Delete, enter the requested confirmation, then select Delete Script to remove it permanently.

Deleting a saved script does not affect servers that were already provisioned with it.


Troubleshooting

If a new server is not configured as expected:

  1. Check the provider console to confirm the server was created and is running.

  2. Open the server console and inspect the cloud-init status:

    cloud-init status --long
  3. Review the cloud-init logs:

    sudo less /var/log/cloud-init.log
    sudo less /var/log/cloud-init-output.log
  4. Correct the saved script and provision a temporary server to test it again.

Cloud-init normally runs during the machine's first boot. Changing the saved template does not repair an existing machine.

On this page