Orchestration
Orchestration, implemented through OpenStack, is crucial for cloud infrastructure management as it enables Infrastructure as Code (IaC) practices by allowing you to describe and automate the deployment of entire cloud environments using template files (like YAML).
Instead of manually creating and configuring resources through the dashboard or CLI commands, orchestration lets you define complete application stacks - including instances, networks, storage, and security groups - in a single template file that can be version-controlled, reused, and consistently deployed across different environments. This automation not only reduces human error and saves time but also ensures reproducibility and scalability of your cloud infrastructure deployments.
OpenStack YML file orchestration
It is also possible to create a yml
file to create the isntance and other resources, this is a template file for a ubuntu
image:
IMPORTANT NOTE: Make suere that you have the OpenStack client installed on your local system. You can install it using pip:
pip install python-openstackclient --upgrade
pip install python-heatclient
File demo-template.yml:
heat_template_version: 2015-10-15
description: Launch a basic instance with Ubuntu image
parameters:
NetID:
type: string
description: Network ID or name to use for the instance.
KeyPair:
type: string
description: Keypair to create the instance.
resources:
server:
type: OS::Nova::Server
properties:
image: Ubuntu server 24.04 (Noble Numbat)
flavor: m1.small
key_name: { get_param: KeyPair }
networks:
- network: { get_param: NetID }
outputs:
instance_name:
description: Name of the instance.
value: { get_attr: [ server, name ] }
instance_ip:
description: IP address of the instance.
value: { get_attr: [ server, first_address ] }
Lauch the yml
file with the command:
source <file>-openrc.sh
openstack stack create -t demo-template.yml --parameter "NetID=test-network;KeyPair=my-keypair-openstack" demo-stack
We used a network called test-network
and the keypair my-keypair-openstack
, both parameters must be already created in colossus cloud.
Terraform orchestration
Using Terraform in an OpenStack environment is important because it allows for infrastructure as code (IaC) management, which provides a consistent, repeatable, and version-controlled way to provision and manage cloud resources. Terraform enables users to define and manage OpenStack resources such as instances, networks, and volumes using a human-readable configuration file, rather than relying on manual CLI commands or GUI interactions.
This approach ensures that infrastructure configurations are predictable, scalable, and easy to reproduce, reducing the risk of human error and configuration drift. Additionally, Terraform's state management capabilities allow for easy tracking of changes and rollbacks, making it an essential tool for managing complex OpenStack environments and ensuring compliance with organizational policies and regulatory requirements. By using Terraform, OpenStack users can streamline their workflow, improve efficiency, and reduce the time and effort required to manage and maintain their cloud infrastructure.
Install terraform: https://developer.hashicorp.com/terraform/install
We can replicate the OpenStack YML file orchestration with Terraform, this are the steps to reproduce the deployment of a single instance. Create a folder containing the following files:
Step 1: Create the OpenStack provider (provider.tf)
provider "openstack" {
user_name = "your-username"
tenant_name = "your-username"
password = "your-password"
auth_url = "https://colossus.cesar.unizar.es:5000/v3"
}
Step 2: Create a variables file (variables.tf)
variable "network_name" {
type = string
default = "test-network"
description = "Network name to use for the instance"
}
variable "keypair_name" {
type = string
default = "my-keypair-openstack"
description = "Keypair name for instance access"
}
Step 3: Create the main terraform file (main.tf)
# Configure OpenStack Provider
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.53.0"
}
}
}
# Create instance
resource "openstack_compute_instance_v2" "demo_instance" {
name = "demo-instance"
image_name = "Ubuntu server 24.04 (Noble Numbat)"
flavor_name = "m1.small"
key_pair = var.keypair_name
network {
name = var.network_name
}
}
# Output instance details
output "instance_name" {
value = openstack_compute_instance_v2.demo_instance.name
}
output "instance_ip" {
value = openstack_compute_instance_v2.demo_instance.access_ip_v4
}
Now, you can launch the commands to create the orchestration in colossus cloud:
terraform init
source <file>-rc.sh
terraform plan
terraform apply
You can debug the terraform deployment by setting the OS_DEBUG=1
variable:
OS_DEBUG=1 TF_LOG=DEBUG terraform apply
Step 4: Destroy instance deployment (optional)
You can rollback the deployment and destroy the instance with the command:
terraform destroy
IMPORTANT: This will destroy the instance and you will lose all your data.
For more information check the terraform documentation: https://developer.hashicorp.com/terraform/docs