Skip to content

Automation & Infrastructure as Code

Clicking through Horizon and the Cloud Services Portal is fine for a first VM, but for repeatable infrastructure you want code. This page points you at the three supported automation paths: the OpenStack CLI (OSC), Terraform, and Ansible.

Prerequisites

  • A Linux workstation (or VM) with egress to the OpenStack API on port 443.
  • Basic shell knowledge.
  • An Application Credential from Horizon (see below).

1. Get an Application Credential

For any automation you need credentials that don't require interactive login. Application Credentials are the recommended option — they're project-scoped, revocable, and don't expose your Horizon password.

In Horizon: Identity → Application Credentials → Create Application Credential. Download the resulting clouds.yaml and place it at ~/.config/openstack/clouds.yaml.

Save the secret now

The Application Credential Secret is shown only once. If you lose it, you must create a new Application Credential.

2. Install the OpenStack CLI (OSC)

OSC unifies compute, identity, image, object storage, and block storage commands into one shell. We recommend installing it inside a Python venv or pyenv.

pip install -U "python-openstackclient<6.1.0" "python-keystoneclient<5.1.0"

Set OS_CLOUD=openstack (matching the top-level key in your clouds.yaml) and verify:

openstack image list

Full OSC installation guide

3. Deploy with OSC

A one-shot VM deploy:

openstack server create vm-u2404-az2 \
   --image "Ubuntu 24.04" \
   --flavor m1.small \
   --key-name foo-key \
   --network foo-net \
   --security-group default \
   --availability-zone ch-zh1-az2

4. Deploy with Terraform

Terraform is the recommended path for production infrastructure — declarative state, plan/apply workflow, and module reuse.

Full Terraform installation guide

resource "openstack_compute_instance_v2" "instance_1" {
   name            = "vm-u2404-az2"
   image_name      = "Ubuntu 24.04"
   flavor_name     = "m1.micro"
   key_pair        = "foo-key"
   security_groups = ["default"]
   availability_zone = "ch-zh1-az2"

   network { name = "foo-net" }
}

5. Deploy with Ansible

If you already run Ansible, the os_server module deploys instances directly:

Full Ansible installation guide

- os_server:
    name: "foo-u2404-az2"
    image: "Ubuntu 24.04"
    key_name: "foo-key"
    flavor: "m1.micro"
    network: "foo-net"
    security_groups: "default"
    availability_zone: "ch-zh1-az2"

OSC / Ansible / Terraform examples

Heat orchestration

Heat (OpenStack's native orchestration engine) is not offered on this platform. Use Terraform or Ansible for infrastructure-as-code.

Next step

You now have the full picture — concepts, login, first VM, first bucket, and automation. The Glossary is your reference for unfamiliar terms, and the rest of the documentation goes deeper: