From b1a5102566d3680fcca4adba363e39edb14bedf6 Mon Sep 17 00:00:00 2001 From: David Lanning Date: Fri, 6 Dec 2024 18:27:54 +0000 Subject: [PATCH] Add the u20->u22 openstack workflow Case RE-1027: Add the u20->u22 openstack workflow Changelog: --- .github/workflows/openstack-ubuntu-20.yml | 632 ++++++++++++++++++ .github/workflows/openstack/reboot_watch | 2 +- .../openstack/ubuntu-20.04/cloud-config.yaml | 5 + .../openstack/ubuntu-20.04/cloud-init.yml | 6 + .../workflows/openstack/ubuntu-20.04/main.tf | 82 +++ .../openstack/ubuntu-20.04/outputs.tf | 7 + .../openstack/ubuntu-20.04/variables.tf | 63 ++ 7 files changed, 796 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/openstack-ubuntu-20.yml create mode 100644 .github/workflows/openstack/ubuntu-20.04/cloud-config.yaml create mode 100644 .github/workflows/openstack/ubuntu-20.04/cloud-init.yml create mode 100644 .github/workflows/openstack/ubuntu-20.04/main.tf create mode 100644 .github/workflows/openstack/ubuntu-20.04/outputs.tf create mode 100644 .github/workflows/openstack/ubuntu-20.04/variables.tf diff --git a/.github/workflows/openstack-ubuntu-20.yml b/.github/workflows/openstack-ubuntu-20.yml new file mode 100644 index 00000000..9bd442ea --- /dev/null +++ b/.github/workflows/openstack-ubuntu-20.yml @@ -0,0 +1,632 @@ +name: "Test Run: ubuntu-20.04" + +on: + push: + branches: + - "main" + - '!docs' + tags-ignore: + - "*" + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-openstack-ubuntu-20.04 + cancel-in-progress: true + +env: + TF_VAR_application_credential_id: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }} + TF_VAR_application_credential_secret: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }} + TF_VAR_github_repository: ${{ github.repository }} + TF_VAR_github_run_id: ${{ github.run_id }} + TF_VAR_ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} + TF_VAR_ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }} + TF_VAR_os_auth_region: ${{ secrets.OS_AUTH_REGION }} + TF_VAR_os_auth_url: ${{ secrets.OS_AUTH_URL }} + TF_VAR_os_interface: ${{ secrets.OS_INTERFACE }} + TF_VAR_os_project_domain_name: ${{ secrets.OS_PROJECT_DOMAIN_NAME }} + TF_VAR_os_password: ${{ secrets.OS_PASSWORD }} + TF_VAR_os_project_id: ${{ secrets.OS_PROJECT_ID }} + TF_VAR_os_project_domain_id: ${{ secrets.OS_PROJECT_DOMAIN_ID }} + TF_VAR_os_project_name: ${{ secrets.OS_PROJECT_NAME }} + TF_VAR_os_region_name: ${{ secrets.OS_REGION_NAME }} + TF_VAR_os_username: ${{ secrets.OS_USERNAME }} + tf_working_directory: "${{ github.workspace }}/.github/workflows/openstack/centos-7" + +jobs: + terraform_openstack_create: + runs-on: self-hosted + defaults: + run: + working-directory: "${{ github.workspace }}/.github/workflows/openstack/ubuntu-20.04" + steps: + - uses: actions/checkout@v4 + - name: Terraform fmt + id: fmt + run: | + terraform fmt -check + continue-on-error: true + + - name: Terraform Init + id: init + run: | + terraform init + + - name: Terraform Plan + id: plan + run: | + terraform plan -no-color + + - name: Terraform Apply + id: apply + run: | + pwd + terraform apply -no-color -auto-approve + mv -v .terraform.lock.hcl terraform.lock.hcl + + - name: Upload Terraform State File as Artifact + uses: actions/upload-artifact@v4.4.3 + with: + name: ${{ github.run_id }}-ubuntu20-terraform.tfstate + path: "${{ github.workspace }}/.github/workflows/openstack/ubuntu-20.04" + + - name: Terraform Output File Create + run: | + terraform output -json > ${{ github.run_id }}-tf.out.json + + - name: Make vm_ip file from Terraform Output File + id: get_vm_ip + run: | + echo "$(jq -r '.address.value' ${{ github.run_id }}-tf.out.json)" > ${{ github.workspace }}/${{ github.run_id }}-vm_ip + + - name: Upload VM Output + uses: actions/upload-artifact@v4.4.3 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/${{ github.run_id }}-vm_ip + overwrite: true + + clone_elevate_repo: + runs-on: self-hosted + needs: terraform_openstack_create + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Checkout Repo and Commit + if: github.event_name != 'pull_request' + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + script: | + cd /opt + echo "## [INFO]: ${{ github.ref }}" + echo "## [INFO]: ${{ github.ref_name }}" + echo "## [INFO}: ${{ github.repository }}" + git clone --depth 1 --branch ${{ github.ref_name }} https://github.com/${{ github.repository }}.git + hostname && pwd && ls -la + cd /opt/$(echo ${{ github.repository }} | cut -d / -f2) + git status + + - name: Checking out Repo and Pull Request + if: github.event_name == 'pull_request' + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + script: | + cd /opt + echo "[DEBUG]: ${{ github.ref }}" + echo "[DEBUG]: ${{ github.head_ref }}" + echo "## [INFO}: ${{ github.repository }}" + git clone --depth 1 --branch ${{ github.head_ref }} https://github.com/${{ github.repository }}.git + cd /opt/$(echo ${{ github.repository }} | cut -d / -f2) + git status + + setup_integration_checks: + runs-on: self-hosted + needs: clone_elevate_repo + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + + - name: Setup for Integration Checks Prior to Running Elevate + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + script: | + REPODIR=$(echo ${{ github.repository }} | cut -d / -f2) + chmod -v +x /opt/${REPODIR}/t/integration/setup + /opt/${REPODIR}/t/integration/setup + + start_elevate: + runs-on: self-hosted + needs: setup_integration_checks + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + + - name: Starting Elevate + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 30m + command_timeout: 30m + script: | + REPODIR=$(echo ${{ github.repository }} | cut -d / -f2) + cp -pv /opt/${REPODIR}/elevate-cpanel /scripts/elevate-cpanel + cp -pv /opt/${REPODIR}/.github/workflows/openstack/status_marker /scripts/status_marker + cp -pv /opt/${REPODIR}/.github/workflows/openstack/reboot_watch /scripts/reboot_watch + /usr/local/cpanel/scripts/post_snapshot --yes + while pgrep -x post_snapshot > /dev/null; do echo "Sleeping until post_snapshot is no longer running as it may be locking apt."; sleep 1; done + /scripts/restartsrv_mysql + chmod -v +x /scripts/elevate-cpanel + until /usr/local/cpanel/cpkeyclt; do echo "Retrying /usr/local/cpanel/cpkeyct until it passes..."; sleep 5; done + /scripts/elevate-cpanel --non-interactive --skip-cpanel-version-check --start & + exit 0 + + wait_for_stage_1_reboot: + runs-on: self-hosted + needs: start_elevate + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Initial Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_stage_2_reboot: + runs-on: self-hosted + needs: wait_for_stage_1_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Reboot from Stage 1 into Stage 2 + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 60m + command_timeout: 30m + debug: true + script: | + /scripts/status_marker 1 + tail -n40 -F /var/log/elevate-cpanel.log & + sleep .5 + REBOOT_STRING="Rebooting into stage 2 of 5" RETVAL=1 /scripts/reboot_watch + + wait_for_stage_2_reboot: + runs-on: self-hosted + needs: watch_for_stage_2_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Stage 2 Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_stage_3_reboot: + runs-on: self-hosted + needs: wait_for_stage_2_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Stage 3 Reboot + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 60m + command_timeout: 30m + debug: true + script: | + /scripts/status_marker 2 + tail -n40 -F /var/log/elevate-cpanel.log & + sleep .5 + REBOOT_STRING="Rebooting into stage 3 of 5" RETVAL=1 /scripts/reboot_watch + + wait_for_stage_3_reboot: + runs-on: self-hosted + needs: watch_for_stage_3_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Stage 3 Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_stage_4_reboot: + runs-on: self-hosted + needs: wait_for_stage_3_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Stage 4 Reboot + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 30m + command_timeout: 30m + script: | + /scripts/status_marker 3 + tail -n40 -F /var/log/elevate-cpanel.log & + sleep .5 + REBOOT_STRING="Rebooting into stage 4 of 5" RETVAL=1 /scripts/reboot_watch + + wait_for_stage_4_reboot: + runs-on: self-hosted + needs: watch_for_stage_4_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Stage 4 Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_stage_5_reboot: + runs-on: self-hosted + needs: wait_for_stage_4_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Stage 5 Reboot + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 45m + command_timeout: 35m + script: | + /scripts/status_marker 4 + tail -n40 -F /var/log/elevate-cpanel.log & + sleep .5 + REBOOT_STRING="Rebooting into stage 5 of 5" RETVAL=1 /scripts/reboot_watch + + wait_for_stage_5_reboot: + runs-on: self-hosted + needs: watch_for_stage_5_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Stage 5 Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + watch_for_final_reboot: + runs-on: self-hosted + needs: wait_for_stage_5_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Monitor Elevate for Final Reboot + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 45m + command_timeout: 35m + script: | + /scripts/status_marker 5 + tail -n40 -F /var/log/elevate-cpanel.log & + sleep 2.5 + SKIP_PID_CHECK=1 REBOOT_STRING="Doing final reboot" RETVAL=1 /scripts/reboot_watch + + wait_for_final_reboot: + runs-on: self-hosted + needs: watch_for_final_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Wait For VM to Come Back From Final Reboot + working-directory: "./.github/workflows/openstack/" + run: | + ./ssh_retry ${{ steps.VM_IP.outputs.VM_IP }} + + verify_upgraded_os: + runs-on: self-hosted + needs: wait_for_final_reboot + outputs: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + steps: + - name: Download VM IP + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-vm_ip + path: ${{ github.workspace }}/ + + - name: Get VM IP from Artifact + id: VM_IP + run: | + echo "VM_IP=$(cat ${{ github.run_id }}-vm_ip)" >> "$GITHUB_OUTPUT" + cat ${{ github.run_id }}-vm_ip > VM_IP + + - name: Export VM_IP to env + env: + VM_IP: ${{ steps.VM_IP.outputs.VM_IP }} + run: echo "VM_IP is ${{ steps.VM_IP.outputs.VM_IP }}" + - name: Verify End Result Integration Tests + uses: appleboy/ssh-action@v1.1.0 + with: + host: ${{ steps.VM_IP.outputs.VM_IP }} + username: 'root' + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: '22' + timeout: 5m + command_timeout: 1m + script: | + REPODIR=$(echo ${{ github.repository }} | cut -d / -f2) + /usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/ubuntu7-to-almalinux8/*.t + /usr/local/cpanel/3rdparty/bin/prove -lvm /opt/${REPODIR}/t/integration/*.t + + terraform_openstack_destroy: + runs-on: self-hosted + needs: verify_upgraded_os + defaults: + run: + working-directory: "${{ github.workspace }}/.github/workflows/openstack/ubuntu-20.04" + steps: + - name: Download Terraform State + uses: actions/download-artifact@v4.1.8 + with: + name: ${{ github.run_id }}-ubuntu20-terraform.tfstate + path: "${{ github.workspace }}/.github/workflows/openstack/ubuntu-20.04/terraform" + + + - name: Stage Files & Show Artifact Paths + run: | + cd ${{ github.workspace }}/.github/workflows/openstack/ubuntu-20.04/terraform/ + mv -v terraform.lock.hcl .terraform.lock.hcl + find ${{ github.workspace }}/.github/workflows/openstack/ubuntu-20.04/ + + - name: Initialize Terraform & Destroy + run: | + cd ${{ github.workspace }}/.github/workflows/openstack/ubuntu-20.04/terraform/ + rm -Rfv .terraform || true + terraform init + terraform destroy -no-color -auto-approve diff --git a/.github/workflows/openstack/reboot_watch b/.github/workflows/openstack/reboot_watch index af5e6c16..a72c4a38 100755 --- a/.github/workflows/openstack/reboot_watch +++ b/.github/workflows/openstack/reboot_watch @@ -34,7 +34,7 @@ sub _check_elevate_log_for_REBOOT_STRING { # Lines that match ERROR or FATAL are an indication that the script # has failed or is about to fail - if ( $line =~ /\[(?:ERROR|FATAL)\[/ ) { + if ( $line =~ /\[(?:ERROR|FATAL)\]|Please fix the detected issues before|You can continue the process after fixing the errors by running|The elevation process failed/ ) { if ( _script_has_failed() ) { # If it failed due to temporary mirror issues, diff --git a/.github/workflows/openstack/ubuntu-20.04/cloud-config.yaml b/.github/workflows/openstack/ubuntu-20.04/cloud-config.yaml new file mode 100644 index 00000000..0445e91b --- /dev/null +++ b/.github/workflows/openstack/ubuntu-20.04/cloud-config.yaml @@ -0,0 +1,5 @@ +--- + users: + - name: root + lock_passwd: false + disable_root: false \ No newline at end of file diff --git a/.github/workflows/openstack/ubuntu-20.04/cloud-init.yml b/.github/workflows/openstack/ubuntu-20.04/cloud-init.yml new file mode 100644 index 00000000..1602682e --- /dev/null +++ b/.github/workflows/openstack/ubuntu-20.04/cloud-init.yml @@ -0,0 +1,6 @@ +#cloud-config +disable_root: false +ssh_pwauth: true +hostname: host +fqdn: host.domain.tbd +prefer_fqdn_over_hostname: true diff --git a/.github/workflows/openstack/ubuntu-20.04/main.tf b/.github/workflows/openstack/ubuntu-20.04/main.tf new file mode 100644 index 00000000..8cd0c920 --- /dev/null +++ b/.github/workflows/openstack/ubuntu-20.04/main.tf @@ -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 = [<> /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 + } + } +} + diff --git a/.github/workflows/openstack/ubuntu-20.04/outputs.tf b/.github/workflows/openstack/ubuntu-20.04/outputs.tf new file mode 100644 index 00000000..396221f0 --- /dev/null +++ b/.github/workflows/openstack/ubuntu-20.04/outputs.tf @@ -0,0 +1,7 @@ +output "address" { + value = openstack_compute_instance_v2.elevatevm.access_ip_v4 +} + +output "id" { + value = openstack_compute_instance_v2.elevatevm.id +} \ No newline at end of file diff --git a/.github/workflows/openstack/ubuntu-20.04/variables.tf b/.github/workflows/openstack/ubuntu-20.04/variables.tf new file mode 100644 index 00000000..a2d1959e --- /dev/null +++ b/.github/workflows/openstack/ubuntu-20.04/variables.tf @@ -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" +}