-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Case RE-1027: Add the u20->u22 openstack workflow Changelog:
- Loading branch information
Travis Holloway
committed
Dec 11, 2024
1 parent
7d0c97a
commit 3865dc9
Showing
8 changed files
with
831 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
users: | ||
- name: root | ||
lock_passwd: false | ||
disable_root: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |