Skip to content

Configure RHEL 9 Equinix Server Vault #95

Configure RHEL 9 Equinix Server Vault

Configure RHEL 9 Equinix Server Vault #95

name: Configure RHEL 9 Equinix Server Vault
on:
repository_dispatch:
types: [custom_restart]
workflow_dispatch:
inputs:
hostname:
description: 'hostname'
required: true
default: hostname
target_server:
description: 'target_server'
required: true
default: rhel9-equinix
forwarder:
description: 'forwarder'
required: true
default: 1.1.1.1
domain:
description: 'domain'
required: true
default: example.com
cicd_env:
description: 'CICD_ENVIORNMENT'
required: true
default: github
type: choice
options:
- github
- gitlab
- onedev
use_route53:
description: 'USE_ROUTE53'
required: true
default: true
zone_name:
description: 'ZONE_NAME'
required: true
default: aws.example.com
guid:
description: 'GUID'
required: true
default: 12345
ollama:
description: 'ollama'
required: true
default: true
env:
TARGET_SERVER: ${{ inputs.target_server }}
DOMAIN: ${{ inputs.domain }}
FORWARDER: ${{ inputs.forwarder }}
CICD_ENVIORNMENT: ${{ inputs.cicd_env }}
USE_ROUTE53: ${{ inputs.use_route53 }}
ZONE_NAME: ${{ inputs.zone_name }}
ACTIVE_BRIDGE: 'false'
INTERFACE: 'bond0'
GUID: ${{ inputs.guid }}
jobs:
configure-rhel9-equinix:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Set Environment Variables
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "TARGET_SERVER=${{ github.event.inputs.target_server }}" >> $GITHUB_ENV
echo "DOMAIN=${{ github.event.inputs.domain }}" >> $GITHUB_ENV
echo "FORWARDER=${{ github.event.inputs.forwarder }}" >> $GITHUB_ENV
echo "HOSTNAME=${{ github.event.inputs.hostname }}" >> $GITHUB_ENV
echo "CICD_ENVIORNMENT=${{ github.event.inputs.cicd_env }}" >> $GITHUB_ENV
echo "USE_ROUTE53=${{ github.event.inputs.use_route53 }}" >> $GITHUB_ENV
echo "ZONE_NAME=${{ github.event.inputs.zone_name }}" >> $GITHUB_ENV
echo "GUID=${{ github.event.inputs.guid }}" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" == "repository_dispatch" ]; then
echo "TARGET_SERVER=${{ github.event.client_payload.data_key.target_server }}" >> $GITHUB_ENV
echo "DOMAIN=${{ github.event.client_payload.data_key.domain }}" >> $GITHUB_ENV
echo "FORWARDER=${{ github.event.client_payload.data_key.forwarder }}" >> $GITHUB_ENV
echo "HOSTNAME=${{ github.event.client_payload.data_key.hostname }}" >> $GITHUB_ENV
echo "CICD_ENVIORNMENT=${{ github.event.inputs.cicd_env }}" >> $GITHUB_ENV
echo "USE_ROUTE53=${{ github.event.inputs.use_route53 }}" >> $GITHUB_ENV
echo "ZONE_NAME=${{ github.event.inputs.zone_name }}" >> $GITHUB_ENV
echo "GUID=${{ github.event.inputs.guid }}" >> $GITHUB_ENV
fi
- name: Configure RHEL 9 Equinix Server
uses: appleboy/[email protected]
with:
host: ${{ env.HOSTNAME }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
command_timeout: 30m
script: |
sudo yum install -y git
if [ -d "/opt/qubinode_navigator" ]; then
cd /opt/qubinode_navigator
git config --global --add safe.directory /opt/qubinode_navigator
git config pull.rebase false
git pull
else
cd /opt/
sudo usermod -aG users ${{ secrets.USERNAME }}
sudo chown -R root:users /opt
sudo chmod -R g+w /opt
git clone https://github.com/tosin2013/qubinode_navigator.git
fi
echo "export CICD_PIPELINE=true" > /opt/qubinode_navigator/.env
echo "export SSH_PASSWORD=${{ secrets.SSH_PASSWORD }}" >> /opt/qubinode_navigator/.env
echo "export INVENTORY='${{ env.TARGET_SERVER }}'" >> /opt/qubinode_navigator/.env
echo "export ENV_USERNAME=${{ secrets.USERNAME }}" >> /opt/qubinode_navigator/.env
echo "export DOMAIN=${{ env.DOMAIN }}" >> /opt/qubinode_navigator/.env
echo "export FORWARDER=${{ env.FORWARDER }}" >> /opt/qubinode_navigator/.env
echo "export ACTIVE_BRIDGE=${{ env.ACTIVE_BRIDGE }}" >> /opt/qubinode_navigator/.env
echo "export INTERFACE=${{ env.INTERFACE }}" >> /opt/qubinode_navigator/.env
echo "export HCP_PROJECT_ID=${{ secrets.HCP_PROJECT_ID }}" >> /opt/qubinode_navigator/.env
echo "export HCP_ORG_ID=${{ secrets.HCP_ORG_ID }}" >> /opt/qubinode_navigator/.env
echo "export HCP_CLIENT_SECRET=${{ secrets.HCP_CLIENT_SECRET }}" >> /opt/qubinode_navigator/.env
echo "export HCP_CLIENT_ID=${{ secrets.HCP_CLIENT_ID }}" >> /opt/qubinode_navigator/.env
echo "export APP_NAME=${{ secrets.APP_NAME }}" >> /opt/qubinode_navigator/.env
echo "export EMAIL=${{ secrets.EMAIL }}" >> /opt/qubinode_navigator/.env
echo "export USE_HASHICORP_CLOUD='true'" >> /opt/qubinode_navigator/.env
echo "export KCLI_PIPELINES_GITHUB_TOKEN=${{ secrets.KCLI_PIPELINES_GITHUB_TOKEN }}" >> /opt/qubinode_navigator/.env
echo "export ZONE_NAME=${{ github.event.inputs.zone_name }}" >> /opt/qubinode_navigator/.env
echo "export GUID=${{ github.event.inputs.guid }}" >> /opt/qubinode_navigator/.env
echo "export USE_ROUTE53=${{ github.event.inputs.use_route53 }}" >> /opt/qubinode_navigator/.env
echo "export OLLAMA_WORKLOAD=${{ github.event.inputs.ollama }}" >> /opt/qubinode_navigator/.env
source /opt/qubinode_navigator/.env && sudo -E /opt/qubinode_navigator/rhel9-linux-hypervisor.sh || exit $?
- name: Send a repository dispatch event to restart the workflow if it failed
if: ${{ failure() }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PAT }}
script: |
async function run() {
try {
await github.repos.createDispatchEvent({
owner: context.repo.owner,
repo: context.repo.repo,
event_type: "custom_restart",
client_payload: {
data_key: {
hostname: '${{ env.HOSTNAME }}',
target_server: '${{ env.TARGET_SERVER }}',
forwarder: '${{ env.FORWARDER }}',
domain: '${{ env.DOMAIN }}'
}
}
});
core.info("Restart dispatched");
} catch (error) {
core.setFailed(`Dispatch failed: ${error.message}`);
}
}
run();