-
Notifications
You must be signed in to change notification settings - Fork 1
157 lines (153 loc) · 6.73 KB
/
configure-rhel9-equinix-vault.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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();