Skip to content

Commit

Permalink
Fixed var definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bordon committed Sep 5, 2024
1 parent 11ee921 commit 39ad0e1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/builder_OVA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- name: Create OVA VM
id: alloc_vm_ova
run: |
instance=$(aws ec2 run-instances --image-id "${{ OVA_AMI }}" --count 1 --instance-type "${{ INSTANCE_TYPE }}" --key-name Ephemeral --security-group-ids "${{ SECURITY_GROUP }}" --subnet-id "${{ SUBNET }}" \
instance=$(aws ec2 run-instances --image-id "${{ env.OVA_AMI }}" --count 1 --instance-type "${{ env.INSTANCE_TYPE }}" --key-name Ephemeral --security-group-ids "${{ env.SECURITY_GROUP }}" --subnet-id "${{ env.SUBNET }}" \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=gha_${{ github.run_id }}_ova_build},{Key=team,Value=devops}]')
INSTANCE_ID=$(echo $instance | jq -r '.Instances[0].InstanceId')
echo "INSTANCE_ID=${INSTANCE_ID}" >> $GITHUB_ENV
Expand All @@ -112,19 +112,19 @@ jobs:
MAX_RETRIES=40
NUM_RETRIES=0
while true; do
STATUS=$(aws ec2 describe-instances --instance-ids "${{ INSTANCE_ID }}" | jq -r '.Reservations[0].Instances[0].State.Name')
STATUS=$(aws ec2 describe-instances --instance-ids "${{ env.INSTANCE_ID }}" | jq -r '.Reservations[0].Instances[0].State.Name')
if [ "${STATUS}" == "running" ]; then
break
fi
sleep 30
NUM_RETRIES=$((NUM_RETRIES+1))
if [ ${NUM_RETRIES} -eq ${MAX_RETRIES} ]; then
echo "Error creating OVA VM"
aws ec2 terminate-instances --instance-ids "${{ INSTANCE_ID }}"
aws ec2 terminate-instances --instance-ids "${{ env.INSTANCE_ID }}"
exit 1
fi
done
ansible_host=$(aws ec2 describe-instances --instance-ids "${{ INSTANCE_ID }}" | jq -r '.Reservations[0].Instances[0].PublicIpAddress')
ansible_host=$(aws ec2 describe-instances --instance-ids "${{ env.INSTANCE_ID }}" | jq -r '.Reservations[0].Instances[0].PublicIpAddress')
mkdir -p /tmp/allocatorvm_ova
echo "[gha_instance]" > /tmp/allocatorvm_ova/inventory
echo "$ansible_host ansible_user=wazuh-user ansible_password=wazuh ansible_ssh_common_args='-o StrictHostKeyChecking=no'" >> /tmp/allocatorvm_ova/inventory
Expand Down Expand Up @@ -196,4 +196,4 @@ jobs:
- name: Delete allocated VM
if: always() && steps.alloc_vm_ova.outcome == 'success'
run: |
aws ec2 terminate-instances --instance-ids "${{ INSTANCE_ID }}"
aws ec2 terminate-instances --instance-ids "${{ env.INSTANCE_ID }}"

0 comments on commit 39ad0e1

Please sign in to comment.