Skip to main content

Install an OS via autoinstallation using Terraform

carefully

Automatic OS installation will delete data on all disks.
Before installing the OS, we recommend saving your data or creating a backup.

You can install the OS via Terraform using automatic installation only. Automatic OS installation is only available for prebuilt servers without upgrades. On a prebuilt server with upgrades, you can manually install the OS from a custom image.

You can install an OS on the server that differs from the current one, or reinstall the current OS.

  1. Open the CLI.

  2. Make sure you are in the directory with the configuration file.

  3. In the selectel_dedicated_os_v1 data source, specify the required OS:

    data "selectel_dedicated_os_v1" "server_os" {
    project_id = selectel_vpc_project_v2.project_1.id
    filter {
    name = "<os_image_name>"
    version_name = "<version_name>"
    configuration_id = data.selectel_dedicated_configuration_v1.server_config.configurations[0].id
    location_id = data.selectel_dedicated_location_v1.server_location.locations[0].id
    }
    }

    Specify:

  4. Check that the configuration file is free of errors:

    terraform validate
  5. Format the configuration file:

    terraform fmt
  6. Check the changes:

    terraform plan
  7. Apply the changes:

    terraform apply
  8. Confirm the creation — type yes and press Enter. The changes will be displayed in the control panel.

  9. Wait for the OS installation to finish.