# Automation

Source: https://docs.quake.ai/docs/automation
Markdown: https://docs.quake.ai/docs/automation.md
> Define Quake AI infrastructure as code with OpenTofu or Terraform for provisioning, and Ansible for configuration management and deployment.

---

# Automation

Declare your Quake AI infrastructure in code, keep it in git, and apply it as often as you need to. These docs use **OpenTofu**, which is open source under MPL-2.0, sits with the Linux Foundation, and reads the same HCL and providers as Terraform. If your team runs Terraform, the templates here work with `terraform` in place of `tofu`.

Once the instances exist, you still have software to install, applications to deploy, and hosts to harden. These docs cover **Ansible** for that layer: OpenTofu provisions on day 0, and Ansible configures on day 1 and after.

## Start here

Follow [Get started with Infrastructure as Code](/docs/automation/how-to/getting-started-iac). You install OpenTofu, authenticate it against your Quake AI project, and apply a first configuration.

## Choose a pattern

| Pattern | Use it when |
| --- | --- |
| [Get started with Infrastructure as Code](/docs/automation/how-to/getting-started-iac) | You have not run OpenTofu against Quake AI yet. |
| [Deploy with OpenTofu](/docs/automation/how-to/terraform-simple) | You want a small instance, network, and volume from HCL. |
| [Template library](/build/iac-templates) | You want to start from an existing configuration instead of writing HCL from scratch. |
| [Configure hosts with Ansible](/docs/automation/how-to/getting-started-ansible) | The VMs already exist and you need Day 1 configuration. |

## How it works

<Figure size="md" caption="OpenTofu workflow: HCL files drive plan and apply, the OpenStack provider creates Quake AI resources, and state is persisted to an S3 backend.">

```mermaid
---
config:
  theme: neutral
  flowchart:
    defaultRenderer: elk
    curve: basis
---
flowchart LR
  accTitle: OpenTofu workflow on Quake AI
  accDescr: HCL files are processed by tofu plan and tofu apply, which call the OpenStack provider to create resources, while state is persisted to a remote S3 backend.

  hcl["main.tf<br/>(HCL)"]
  plan["tofu plan"]
  apply["tofu apply"]
  provider["OpenStack provider"]
  state[("Remote state<br/>S3 backend")]

  subgraph rc["Quake AI resources"]
    direction TB
    inst["Instances"]
    net["Networks"]
    vol["Volumes"]
    sg["Security groups"]
  end

  hcl --> plan
  plan --> apply
  apply --> provider
  provider --> rc
  apply <--> state
```

</Figure>

OpenTofu and Terraform use the [OpenStack provider](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs) to manage Quake AI resources. You write `.tf` files declaring the desired state (instances, networks, volumes, security groups), and the tool calculates the diff, plans changes, and applies them. State lives locally or in a remote backend; Quake AI object storage works as an S3-compatible backend for remote state.

These docs lead with OpenTofu because it is open source, speaks the same HCL and provider ecosystem as Terraform, and handles state, module reuse, and CI/CD the same way.

## Concepts

<DocsSectionLinks section="automation/concepts" grouping="concepts" />

## How-to

<DocsSectionLinks section="automation/how-to" />

## Migration

<DocsSectionLinks section="automation/migration" />

## Related builds

<RelatedBuilds service="automation" />

## Reference and operations

<ReferenceServiceLinks service="automation" />

<ReferenceConsoleLinks service="automation" />

When an apply fails on a Heat stack or an instance never reaches a running state, [Operations](/docs/operations) has the runbooks for both.

## Heat orchestration

Quake AI runs [Heat](https://docs.openstack.org/heat/latest/), so the stacks you already have keep working. Start new work in OpenTofu. For more on the OpenStack services underneath, see [How Quake AI uses OpenStack](/docs/platform/migration/openstack).

- [Create a Heat stack](/docs/automation/how-to/create-heat-stack)
- [Heat Simple Stack template](/build/iac-templates/heat-simple-stack)

A configuration can create resources in [Compute](/docs/compute), [Network](/docs/network), [Block storage](/docs/block), and [Kubernetes](/docs/kubernetes). Keep the state file in [Object storage](/docs/object), which works as an S3 backend.
