Skip to content

Commit

Permalink
Add the u20->u22 openstack workflow
Browse files Browse the repository at this point in the history
Case RE-1027: Add the u20->u22 openstack workflow

Changelog:
  • Loading branch information
Travis Holloway committed Dec 11, 2024
1 parent 7d0c97a commit 3865dc9
Show file tree
Hide file tree
Showing 8 changed files with 831 additions and 0 deletions.
643 changes: 643 additions & 0 deletions .github/workflows/openstack-ubuntu-20.yml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .github/workflows/openstack/ubuntu-20.04/cloud-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
users:
- name: root
lock_passwd: false
disable_root: false
6 changes: 6 additions & 0 deletions .github/workflows/openstack/ubuntu-20.04/cloud-init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#cloud-config
disable_root: false
ssh_pwauth: true
hostname: host
fqdn: host.domain.tbd
prefer_fqdn_over_hostname: true
82 changes: 82 additions & 0 deletions .github/workflows/openstack/ubuntu-20.04/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.54.1"
}
}
}

# Configure the OpenStack Provider
provider "openstack" {
user_name = var.user
application_credential_id = var.application_credential_id
application_credential_secret = var.application_credential_secret
auth_url = "https://keystone.hou-01.cloud.prod.cpanel.net:5000/v3"
region = var.os_auth_region
}

data "openstack_images_image_ids_v2" "images" {
name_regex = var.image_name
sort = "updated_at"
}

data "template_cloudinit_config" "config" {
gzip = true
base64_encode = true

part {
content_type = "text/cloud-config"
content = "cloud-config.yaml"
}
}

resource "tls_private_key" "ssh" {
algorithm = "ECDSA"
ecdsa_curve = "P384"
}

resource "random_string" "keyname" {
length = 22
special = false
}

resource "openstack_compute_keypair_v2" "tf_remote_key" {
name = "${random_string.keyname.result}-deletethis"
public_key = tls_private_key.ssh.public_key_openssh
}

resource "openstack_compute_instance_v2" "elevatevm" {
name = "${var.github_run_id}.${var.github_repository}.github.cpanel.net"
image_id = data.openstack_images_image_ids_v2.images.ids[0]
flavor_name = var.flavor_name
key_pair = openstack_compute_keypair_v2.tf_remote_key.name
user_data = data.template_cloudinit_config.config.rendered
network {
name = "hou-prod-external"
}

provisioner "remote-exec" {
inline = [<<EOF
echo "START_REMOTE_EXEC"
touch /root/.ssh/id_ed25519
chmod 600 /root/.ssh/id_ed25519
echo "${var.ssh_private_key}" >> /root/.ssh/id_ed25519
echo "${var.ssh_public_key}" >> /root/.ssh/authorized_keys
echo 'waiting on cloud-init...'
cloud-init status --wait > /dev/null || true
EOF
]
connection {
type = "ssh"
agent = "false"
host = self.access_ip_v4
user = "root"
script_path = "/root/elevate_bootstrap"
private_key = tls_private_key.ssh.private_key_pem
}
}
}

7 changes: 7 additions & 0 deletions .github/workflows/openstack/ubuntu-20.04/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "address" {
value = openstack_compute_instance_v2.elevatevm.access_ip_v4
}

output "id" {
value = openstack_compute_instance_v2.elevatevm.id
}
63 changes: 63 additions & 0 deletions .github/workflows/openstack/ubuntu-20.04/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
variable "user" {
type = string
default = "resu"
}

variable "application_credential_id" {
type = string
}

variable "application_credential_secret" {
type = string
}

variable "os_password" {
type = string
}

variable "github_repository" {
type = string
}

variable "github_run_id" {
type = string
}

variable "os_auth_region" {
type = string
}

variable "os_auth_url" {
type = string
}

variable "os_project_domain_name" {
type = string
}

variable "ssh_private_key" {
type = string
description = "SSH private key matching the public key added to the VMs /root/.ssh/authorized_keys file to allow user access."
sensitive = true
}

variable "ssh_public_key" {
type = string
description = "SSH public key matching the public key added to the VMs /root/.ssh/authorized_keys file to allow user access."
sensitive = true
}

variable "image_name" {
type = string
default = "11.118.0.* on Ubuntu 20.04"
}

variable "cpanel_release_version" {
type = string
default = "110"
}

variable "flavor_name" {
type = string
default = "c2.d20.r2048"
}
8 changes: 8 additions & 0 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,11 @@ jobs:
(github.event_name == 'pull_request' && github.base_ref == 'main') ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
Ubuntu-20:
needs: testsuite
uses: ./.github/workflows/openstack-ubuntu-20.yml
secrets: inherit
if: >
(github.event_name == 'pull_request' && github.base_ref == 'main') ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
17 changes: 17 additions & 0 deletions t/integration/ubuntu20-to-ubuntu22/complete.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/local/cpanel/3rdparty/bin/perl

# Copyright 2024 WebPros International, LLC
# All rights reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.

use lib '/usr/local/cpanel/';

use Cpanel::OS ();

use Test::More;

is( Cpanel::OS->distro(), 'ubuntu', 'System is Ubuntu after upgrade.' );
is( Cpanel::OS->major(), '22', 'Verson 22 of OS.' );

done_testing();

0 comments on commit 3865dc9

Please sign in to comment.