Configuration scripts in cloud instance creation (cloud-init)

Note: Configuration scripts in xneelo Cloud are best suited for Linux-based instances, which support cloud-init by default.

Configuration scripts (also known as user-data scripts, or cloud-init scripts) let you automate server setup tasks of a new cloud instance during its creation. 

In xneelo Cloud, you can write your own cloud-init configuration scripts and apply them during instance creation. This helps save time and ensure consistency across your instances.

In this article, we’ll explain how configuration scripts work and how to use them effectively.


  • What is a configuration script?

    A configuration script is a small block of code (usually in YAML format) that provides setup instructions for a cloud instance.

    These scripts are powered by cloud-init, an industry-standard tool that automates instance initialisation. 

    Cloud-init runs during the first boot of a new instance (only once), and reads your script to apply the configurations.

    Configuration scripts can be added during instance creation, under the Config & Password tab.





  • Why use a configuration script?

    Using a configuration script helps automate your cloud workflows. They make it easier to:

    • Ensure repeatable instance setup across environments
    • Speed up provisioning by pre-installing dependencies
    • Reduce manual configuration errors
    • Enforce security and access settings consistently

    Configuration scripts are especially useful when spinning up multiple instances or when you want to standardise your infrastructure setup.





  • Common use cases

    Configuration scripts are highly flexible and can be used to automate various system administration tasks. Some common use cases include:

    • Creating users and setting passwords:
      Set a default password, create new user passwords, set roles, and assign admin privileges.
    • Installing software packages:
      Automatically install packages, dependencies, or development tools.
    • Running shell commands or scripts:
      Execute custom shell commands or scripts to configure services, clone repositories, set environment variables, or run custom setup logic.
    • Writing files to the instance:
      Automatically create configuration files, environment variables, or other system files.
    • Customising SSH access:
      Add additional SSH public keys access, enable or disable password-based login.
    • Setting up firewalls or services:
      Enable and configure system services, or set up firewall rules.





    • Creating your own scripts

      You can write your own cloud-init configuration scripts and apply them during instance creation.

      For more advanced setups, refer to the official cloud-init documentation, which includes an extensive list of cloud config YAML examples.

      See the cloud config examples library.

      If your script doesn’t work as expected:

      Note: It is your responsibility to ensure that your configuration is correctly written and formatted. If your script fails to load or causes issues, our support team will not be able to assist. This falls outside the scope of support.



    Assist Note

    Now that you’re familiar with configuration scripts, you can put them into practice by creating a new cloud instance and testing your setup.

    Try using one of the example scripts above, or create your own to automate your preferred configuration.