VM Deployment
OpenStack Client (also known as OSC) is a command-line client for OpenStack that unifies the command set for Compute, Identity, Image, Object Storage, and Block Storage APIs in a single shell with a consistent command structure.
This chapter includes examples of how a VM can be deployed using OSC, Ansible, or Terraform.
Prerequisites
- The CLI used (OSC, Ansible, or Terraform) must be installed and configured
- Basic knowledge of the Linux operating system (shell)
- Access to a running Linux VM (Ubuntu in our example) with an open port (Egress 443) to the OpenStack API
- Application Credentials (cloud.yaml)
Instructions for installing and configuring OpenStack OSC (see: config-osc).
In the following examples, a VM with Ubuntu 24.04 is deployed into the Availability Zone ch-zh1-az2.
Example Deploying a VM with OpenStack CLI (OSC)
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
Example Deploying a VM with Ansible
- 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"
Example Deploying a VM with Terraform
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"
}
}
How to Deploy a Volume with OSC - Ansible or Terraform
In the following examples, a 10GB volume is deployed into the Availability Zone ch-zh1-az2.
Example Deploying a Volume with OpenStack CLI (OSC)
openstack volume create vol1-az2 \
--size 10 \
--availability-zone ch-zh1-az2
Example Deploying a Volume with Ansible
- os_volume:
display_name: "vol1-az2"
size: 10
availability_zone: "ch-zh1-az2"
Example Deploying a Volume with Terraform
``` shell resource "openstack_blockstorage_volume_v2" "volume_1" { name = "vol1-az2" size = 10 availability_zone = "ch-zh1-az2"