# How to customize a template's image and flavor

Source: https://docs.quake.ai/docs/automation/how-to/customize-template-image-flavor
Markdown: https://docs.quake.ai/docs/automation/how-to/customize-template-image-flavor.md

---

# How to customize a template's image and flavor

Change the operating system image or hardware size on an OpenTofu template you already deployed. This guide applies to any template under [Automation templates](/resources/iac-templates) that exposes `image_name` and flavor variables in `variables.tf`. Image and flavor names must match Quake AI catalog literals; see [Authoring IaC templates for Quake AI](/docs/automation/concepts/authoring-iac-templates) for the full naming rules and template conventions.

<PrerequisiteBlock methods={["console", "cli", "terraform"]}>

- You deployed a template from `iac/templates/` (or copied its HCL into your own project) and ran `tofu init` in that directory
- OpenTofu or Terraform installed and Quake AI credentials configured (see [Get started with IaC](/docs/automation/how-to/getting-started-iac))
- Enough project quota for the target flavor (run `openstack limits show --absolute` if you are sizing up)

</PrerequisiteBlock>

## Locate the image and flavor variables

Open `variables.tf` in your template directory. Every compute-backed template declares an `image_name` variable and at least one flavor variable. The flavor variable name differs by template:

| Template | Flavor variable(s) | Default image |
| --- | --- | --- |
| [simple-vm](/resources/iac-templates/simple-vm), [edge-reverse-proxy](/resources/iac-templates/edge-reverse-proxy), [containerized-app](/resources/iac-templates/containerized-app) | `flavor_name` | `Ubuntu-24.04` |
| [wordpress-mysql](/resources/iac-templates/wordpress-mysql) | `wp_flavor`, `db_flavor` | `Ubuntu-24.04` |
| [full-stack-app](/resources/iac-templates/full-stack-app), [three-tier-app](/resources/iac-templates/three-tier-app) | `web_flavor`, `app_flavor`, `db_flavor` | `Ubuntu-24.04` |
| [k8s-cluster](/resources/iac-templates/k8s-cluster) | `cp_flavor`, `worker_flavor` | `Ubuntu-24.04` |
| [dev-environment](/resources/iac-templates/dev-environment) | `flavor_name`, `bastion_flavor` | `Ubuntu-24.04` |

The [simple-vm](/resources/iac-templates/simple-vm) template wires these variables into a Glance data source and the instance resource:

```hcl
data "openstack_images_image_v2" "os" {
  name        = var.image_name
  most_recent = true
}

resource "openstack_compute_instance_v2" "vm" {
  flavor_name = var.flavor_name
  # ...
  block_device {
    uuid = data.openstack_images_image_v2.os.id
    # ...
  }
}
```

The [wordpress-mysql](/resources/iac-templates/wordpress-mysql) template uses one shared `image_name` for both instances but separate flavor variables:

```hcl
resource "openstack_compute_instance_v2" "wordpress" {
  flavor_name = var.wp_flavor
  # ...
}

resource "openstack_compute_instance_v2" "mysql" {
  flavor_name = var.db_flavor
  # ...
}
```

Templates look up images by **name**, so the value you set must match a Glance image name exactly (for example `Ubuntu-24.04`, not `Ubuntu 24.04`).

## Choose an image and flavor

<MethodTabs>
<Method label="Console">

### Browse available images

1. Open the Console and go to **Compute** > **Images** > **Public Images**.
2. Note the catalog name for the image you want. Public images use hyphenated names such as `Ubuntu-24.04`, `Ubuntu-22.04`, `AlmaLinux-9`, and `Rocky-9`.

See [Images console reference](/reference/compute/console/images) for the full public catalog.

### Browse available flavors

1. Go to **Compute** > **Instances** > **Create Instance**.
2. On **Base Config**, open the **Specification** section. Flavors appear under category tabs: **General Purpose**, **Compute Optimized**, **Memory Optimized**, and **Shared Resources**.
3. Note the flavor name (for example `s1a.small`, `c2a.large`, `m2a.large`). You do not need to finish creating an instance.

See [Flavors console reference](/reference/compute/console/flavors) for vCPU, RAM, and category details.

</Method>
<Method label="CLI">

List public and private images:

```bash
openstack image list -f value -c Name
```

Example output includes `Ubuntu-24.04`, `Ubuntu-22.04`, and `AlmaLinux-9`. Use the name column value verbatim in your template variables.

List flavors with vCPU and RAM columns:

```bash
openstack flavor list -f table -c Name -c VCPUs -c RAM
```

Inspect one flavor before you apply it:

```bash
openstack flavor show m2a.large
```

Flavors are grouped into General Purpose, Compute Optimized, Memory Optimized, and Shared Resources categories on Quake AI. See [Flavors](/docs/compute/concepts/flavors) for guidance on picking a category.

All Quake AI flavors report `disk=0`. Templates boot from a Cinder volume defined in the `block_device` block, so you do not pick root disk size through the flavor.

</Method>
<Method label="Terraform">

You can confirm that a name resolves before you apply by adding a one-off data source in your template directory:

```hcl
data "openstack_images_image_v2" "probe" {
  name        = "Rocky-9"
  most_recent = true
}

data "openstack_compute_flavor_v2" "probe" {
  name = "c2a.large"
}

output "probe" {
  value = {
    image_id   = data.openstack_images_image_v2.probe.id
    flavor_ram = data.openstack_compute_flavor_v2.probe.ram
  }
}
```

Run `tofu plan` to verify both data sources resolve. Remove the probe block after you confirm the names, or keep it as a pre-flight check in a separate `probe.tf` file you delete before production applies.

</Method>
</MethodTabs>

## Set the new image or flavor

Pick one override mechanism. Use the same approach for every subsequent change so your team knows where values live.

### Option A: `terraform.tfvars` (recommended)

Create or edit `terraform.tfvars` in the template directory:

```hcl
image_name  = "Rocky-9"
flavor_name = "c2a.large"
```

For [wordpress-mysql](/resources/iac-templates/wordpress-mysql):

```hcl
image_name = "Ubuntu-22.04"
wp_flavor  = "s1a.medium"
db_flavor  = "m2a.large"
```

OpenTofu loads `terraform.tfvars` automatically on every plan and apply.

### Option B: `-var` on the command line

```bash
tofu plan \
  -var 'image_name=Rocky-9' \
  -var 'flavor_name=c2a.large'
```

Repeat each `-var` flag for every flavor variable your template defines.

### Option C: edit the default in `variables.tf`

Change the `default` attribute on the variable block. This works for a personal fork but makes upstream merges harder, so prefer `terraform.tfvars` for values you change often.

## Plan and apply the change

From the template directory:

```bash
tofu plan
tofu apply
```

Read the plan carefully:

- **Image change:** OpenTofu marks affected `openstack_compute_instance_v2` resources with `-/+` or `forces replacement` because the boot volume is rebuilt from the new Glance image. Plan for brief downtime and a new root volume.
- **Flavor change:** A larger flavor usually updates in place. Downgrading RAM may require replacement depending on the instance state; the plan output shows `forces replacement` when OpenTofu cannot resize in place.

If the plan fails with `Your query returned no results`, the image or flavor name does not match the catalog. Re-run `openstack image list` or `openstack flavor list` and copy the name exactly.

## Verify the new image and flavor

After `tofu apply` completes, confirm the running instances match your overrides.

```bash
openstack server list -f table -c Name -c Flavor -c Image
```

For a single instance:

```bash
openstack server show INSTANCE_NAME -c flavor -c image -f yaml
```

If the template exposes addresses in `outputs.tf` (as [simple-vm](/resources/iac-templates/simple-vm) does), retrieve them with:

```bash
tofu output
```

SSH to the instance and check the OS when you changed `image_name`. Replace `YOUR_USER` with the default SSH user for your image. See [default usernames by distribution](/docs/compute/how-to/create-password#default-usernames-by-distribution).

```bash
ssh -i ~/.ssh/YOUR_KEY YOUR_USER@FLOATING_IP cat /etc/os-release
```

## See also

- [Authoring IaC templates for Quake AI](/docs/automation/concepts/authoring-iac-templates)
- [Automation templates](/resources/iac-templates): reference pages for all 13 templates
- [Flavors](/docs/compute/concepts/flavors): category overview and sizing guidance
- [Images CLI reference](/reference/compute/images-cli): full `openstack image` command set
- [Flavors CLI reference](/reference/compute/flavors-cli): full `openstack flavor` command set
- [How to manage multiple environments with OpenTofu](/docs/automation/how-to/multi-environment): per-environment tfvars files
- [How to debug Terraform errors](/docs/automation/how-to/terraform-error-handling): data-source name mismatches and quota errors
