mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2026-03-20 03:41:54 +00:00
* Create composite action for dynamic virtual AP EC2 instance deployment Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Fix output description Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Fix step output name Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Checkout repo before using composite action Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Switch to inputs in composite action since secrets do not work Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Move env variable definition to step section Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Remove top level env section Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Fix job and step outputs Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Use SSH option to start ucentral in background Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Switch to SSH password until config override option is ready Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Adapt workflow to previous changes Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Remove key reference in SSH command line options Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Add instance_id output and switch to cut to get firmware version Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Fix terminate-instances command Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Switch back to awk command to get firmware version Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Wait for automated ucentral start before stopping and fix awk command Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Add owner tag to run-instances command Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org> * Remove branch reference Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
67 lines
3.7 KiB
YAML
67 lines
3.7 KiB
YAML
name: Deploy virtual AP instance
|
|
description: create EC2 instance running latest wlan-ap release and connect to gateway
|
|
|
|
inputs:
|
|
virtual_ap_password:
|
|
description: SSH password used to connect to virtual AP instance
|
|
required: true
|
|
virtual_ap_cert:
|
|
description: AP cert which is uploaded and used to connect to the gateway
|
|
required: true
|
|
virtual_ap_key:
|
|
description: AP key which is uploaded and used to connect to the gateway
|
|
required: true
|
|
virtual_ap_dev_id:
|
|
description: Dev-id associated with the AP cert
|
|
required: true
|
|
gateway_url:
|
|
description: URL of the gateway the virtual AP should connect to
|
|
required: true
|
|
|
|
outputs:
|
|
serial_number:
|
|
description: Serial number of the created virtual AP instance
|
|
value: ${{ steps.get_virtual_ap_facts.outputs.serial_number }}
|
|
instance_id:
|
|
description: ID of the created virtual AP EC2 instance
|
|
value: ${{ steps.get_virtual_ap_facts.outputs.instance_id }}
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Get AMI ID of most recent x64_vmware firmware image
|
|
shell: bash
|
|
id: get_ami_id
|
|
run: |
|
|
echo ::set-output name=id::"$(aws ec2 describe-images --owners self --filters 'Name=name,Values=*-x64_vmware-*' --query 'sort_by(Images, &CreationDate)[-1].ImageId' --output text)"
|
|
|
|
- name: Create openwifi-virtual-ap EC2 instance
|
|
shell: bash
|
|
run: |
|
|
aws ec2 run-instances --key-name openwifi-virtual-ap --security-groups openwifi-virtual-ap --instance-type t2.nano --image-id ${{ steps.get_ami_id.outputs.id }} --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=openwifi-virtual-ap-${{ github.run_id }}},{Key=Owner,Value=gha-wlan-testing}]'
|
|
|
|
- name: Get virtual AP instance facts
|
|
shell: bash
|
|
id: get_virtual_ap_facts
|
|
run: |
|
|
echo ::set-output name=public_ip::"$(aws ec2 describe-instances --filters 'Name=tag:Name,Values=openwifi-virtual-ap-${{ github.run_id }}' --query 'Reservations[*].Instances[*].PublicIpAddress' --output text)"
|
|
echo ::set-output name=serial_number::"$(aws ec2 describe-instances --filters 'Name=tag:Name,Values=openwifi-virtual-ap-${{ github.run_id }}' --query 'Reservations[*].Instances[*].NetworkInterfaces[*].MacAddress' --output text | sed 's/://g')"
|
|
echo ::set-output name=instance_id::"$(aws ec2 describe-instances --filters 'Name=tag:Name,Values=openwifi-virtual-ap-${{ github.run_id }}' --query 'Reservations[*].Instances[*].InstanceId' --output text)"
|
|
|
|
- name: Upload AP certificate, key and dev-id to instance
|
|
env:
|
|
VIRTUAL_AP_PASSWORD: ${{ inputs.virtual_ap_password }}
|
|
VIRTUAL_AP_CERT: ${{ inputs.virtual_ap_cert }}
|
|
VIRTUAL_AP_KEY: ${{ inputs.virtual_ap_key }}
|
|
VIRTUAL_AP_DEV_ID: ${{ inputs.virtual_ap_dev_id }}
|
|
shell: bash
|
|
run: |
|
|
sshpass -p ${{ env.VIRTUAL_AP_PASSWORD }} ssh -o StrictHostKeyChecking=accept-new root@${{ steps.get_virtual_ap_facts.outputs.public_ip }} 'echo "${{ env.VIRTUAL_AP_CERT }}" > /etc/ucentral/cert.pem; echo "${{ env.VIRTUAL_AP_KEY }}" > /etc/ucentral/key.pem && chmod 600 /etc/ucentral/key.pem; echo "${{ env.VIRTUAL_AP_DEV_ID }}" > /etc/ucentral/dev-id; sleep 10'
|
|
|
|
- name: Stop ucentral service on AP and connect manually to gateway
|
|
env:
|
|
VIRTUAL_AP_PASSWORD: ${{ inputs.virtual_ap_password }}
|
|
shell: bash
|
|
run: |
|
|
sshpass -p ${{ env.VIRTUAL_AP_PASSWORD }} ssh -f -o StrictHostKeyChecking=accept-new root@${{ steps.get_virtual_ap_facts.outputs.public_ip }} "/etc/init.d/ucentral stop; /usr/sbin/ucentral -S ${{ steps.get_virtual_ap_facts.outputs.serial_number }} -s ${{ inputs.gateway_url }} -P 15002 -d -f \$(awk -F '=' 'FNR == 8 {print \$2}' /etc/openwrt_release | tr -d \') &> /dev/null"
|