Commit 9847f33b authored by nanahira's avatar nanahira

use built-in envs

parent 879ec8d7
/ssh
/config
.git*
Dockerfile
config.example
README.md
LICENSE
export GOVC_USERNAME=administrator@example.com
export GOVC_PASSWORD=password_here
export GOVC_URL=vc.example.com
export DATACENTER=example
export VC_HOST=host.example.com
export RESOURCE_POOL=example
export DATASTORE=example-datastore1
export NETWORK=example-runners
export TEMPLATE=runner-template-example
export CPU_COUNT=2
export MEM_COUNT=4096
export SSH_USER=root
......@@ -6,5 +6,5 @@ source ${currentDir}/../config # config file
VM_ID="runner-$CUSTOM_ENV_CI_RUNNER_ID-project-$CUSTOM_ENV_CI_PROJECT_ID-concurrent-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID-job-$CUSTOM_ENV_CI_JOB_ID"
_get_vm_ip() {
govc vm.info "-dc=$DATACENTER" -json "$VM_ID" | jq .VirtualMachines[0].Guest.IpAddress | sed 's/"//g'
govc vm.info "-dc=$VC_DATACENTER" -json "$VM_ID" | jq .VirtualMachines[0].Guest.IpAddress | sed 's/"//g'
}
......@@ -8,4 +8,4 @@ source ${currentDir}/base # Get variables from base script.
set -eo pipefail
# Destroy VM.
govc vm.destroy "-dc=$DATACENTER" "$VM_ID"
govc vm.destroy "-dc=$VC_DATACENTER" "$VM_ID"
......@@ -11,7 +11,7 @@ set -eo pipefail
trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR
# Install the VM
govc vm.clone "-dc=$DATACENTER" -on=true -waitip=true "-vm=$TEMPLATE" "-host=$VC_HOST" "-pool=$RESOURCE_POOL" "-ds=$DATASTORE" "-net=$NETWORK" "-c=$CPU_COUNT" "-m=$MEM_COUNT" "$VM_ID"
govc vm.clone "-dc=$VC_DATACENTER" -on=true -waitip=true "-vm=$VC_TEMPLATE" "-host=$VC_HOST" "-pool=$VC_RESOURCE_POOL" "-ds=$VC_DATASTORE" "-net=$VC_NETWORK" "-c=$VC_CPUS" "-m=$VC_MEMS" "$VM_ID"
# Wait for VM to get IP
echo 'Waiting for VM to get IP'
......@@ -36,7 +36,7 @@ done
# Wait for ssh to become available
echo "Waiting for sshd to be available"
for i in $(seq 1 30); do
if ssh -i "${currentDir}/../ssh/id_rsa" -o StrictHostKeyChecking=no "$SSH_USER@$VM_IP" >/dev/null 2>/dev/null; then
if ssh -i "${currentDir}/../ssh/id_rsa" -o StrictHostKeyChecking=no "$VC_SSH_USER@$VM_IP" >/dev/null 2>/dev/null; then
break
fi
......
......@@ -7,7 +7,7 @@ source ${currentDir}/base # Get variables from base script.
VM_IP=$(_get_vm_ip)
ssh -i "${currentDir}/../ssh/id_rsa" -o StrictHostKeyChecking=no "$SSH_USER@$VM_IP" /bin/bash < "${1}"
ssh -i "${currentDir}/../ssh/id_rsa" -o StrictHostKeyChecking=no "$VC_SSH_USER@$VM_IP" /bin/bash < "${1}"
if [ $? -ne 0 ]; then
# Exit using the variable, to make the build as failure in GitLab
# CI.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment