diff --git a/bib-image.sh b/bib-image.sh index 8397ed2..8e0f246 100755 --- a/bib-image.sh +++ b/bib-image.sh @@ -233,8 +233,6 @@ case "$IMAGE_TYPE" in "$TEST_IMAGE_URL" greenprint "Deploy $IMAGE_TYPE instance" - sudo curl -L -o - "https://github.com/vmware/govmomi/releases/latest/download/govc_$(uname -s)_$(uname -m).tar.gz" | sudo tar -C /usr/local/bin -xvzf - govc - DATACENTER_70="Datacenter7.0" DATASTORE_70="datastore-80" DATACENTER_70_POOL="/Datacenter7.0/host/Automation/Resources" diff --git a/os-replace.sh b/os-replace.sh index 363ce23..0e06de2 100755 --- a/os-replace.sh +++ b/os-replace.sh @@ -80,6 +80,20 @@ EOF ;; esac +greenprint "Configure container build arch" +case "$ARCH" in + "x86_64") + BUILD_PLATFORM="linux/amd64" + ;; + "aarch64") + BUILD_PLATFORM="linux/arm64" + ;; + *) + redprint "Variable ARCH has to be defined" + exit 1 + ;; +esac + if [[ ${AIR_GAPPED-} -eq 1 ]];then if [[ ${PLATFORM} == "libvirt" ]]; then AIR_GAPPED_DIR="$TEMPDIR"/virtiofs @@ -128,9 +142,9 @@ cat "$INSTALL_CONTAINERFILE" greenprint "Build $TEST_OS installation container image" if [[ "$LAYERED_IMAGE" == "useradd-ssh" ]]; then - podman build --tls-verify=false --retry=5 --retry-delay=10 --build-arg "sshpubkey=$(cat "${SSH_KEY_PUB}")" -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$LAYERED_DIR" + podman build --platform "$BUILD_PLATFORM" --tls-verify=false --retry=5 --retry-delay=10 --build-arg "sshpubkey=$(cat "${SSH_KEY_PUB}")" -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$LAYERED_DIR" else - podman build --tls-verify=false --retry=5 --retry-delay=10 -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$LAYERED_DIR" + podman build --platform "$BUILD_PLATFORM" --tls-verify=false --retry=5 --retry-delay=10 -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$LAYERED_DIR" fi greenprint "Push $TEST_OS installation container image" @@ -194,7 +208,7 @@ RUN dnf -y install wget && \ EOF greenprint "Build $TEST_OS upgrade container image" -podman build --tls-verify=false --retry=5 --retry-delay=10 -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" -f "$UPGRADE_CONTAINERFILE" . +podman build --platform "$BUILD_PLATFORM" --tls-verify=false --retry=5 --retry-delay=10 -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" -f "$UPGRADE_CONTAINERFILE" . greenprint "Push $TEST_OS upgrade container image" retry podman push --tls-verify=false --quiet "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$TEST_IMAGE_URL" diff --git a/playbooks/deploy-aws.yaml b/playbooks/deploy-aws.yaml index 327bf9b..fcf5af7 100644 --- a/playbooks/deploy-aws.yaml +++ b/playbooks/deploy-aws.yaml @@ -53,61 +53,72 @@ - layered_image | default('') == "nvidia" and arch == "aarch64" - name: "get available zone for instance {{ random_instance_type }}" - shell: aws ec2 describe-instance-type-offerings --location-type availability-zone --filters="Name=instance-type,Values={{ random_instance_type }}" --query InstanceTypeOfferings | jq -r '.[0].Location' + shell: | + aws ec2 describe-instance-type-offerings \ + --location-type availability-zone \ + --filters="Name=instance-type,Values={{ random_instance_type }}" \ + --query InstanceTypeOfferings | jq -r '.[0].Location' register: ec2_zone when: "'rhel' not in test_os" - name: get subnet - amazon.aws.ec2_vpc_subnet_info: - filters: - "tag:Name": "kite-ci" - "availabilityZone": "{{ ec2_zone.stdout }}" + shell: | + aws ec2 describe-subnets \ + --output json \ + --filters "Name=tag:Name,Values=kite-ci" "Name=availabilityZone,Values={{ ec2_zone.stdout }}" | \ + jq -r ".Subnets[0].SubnetId" register: ec2_vpc_subnet when: "'rhel' not in test_os" - set_fact: - subnet_id: "{{ ec2_vpc_subnet.subnets[0].subnet_id }}" + subnet_id: "{{ ec2_vpc_subnet.stdout }}" when: "'rhel' not in test_os" - name: get virtqe subnet - amazon.aws.ec2_vpc_subnet_info: - filters: - "tag:Name": "InternalA-virtqe" + shell: | + aws ec2 describe-subnets \ + --output json \ + --filters "Name=tag:Name,Values=InternalA-virtqe" | \ + jq -r ".Subnets[0].SubnetId" register: ec2_vpc_subnet when: '"rhel" in test_os' - set_fact: - subnet_id: "{{ ec2_vpc_subnet.subnets[0].subnet_id }}" + subnet_id: "{{ ec2_vpc_subnet.stdout }}" when: "'rhel' in test_os" - name: get security group - amazon.aws.ec2_security_group_info: - filters: - "tag:Name": "kite-ci" + shell: | + aws ec2 describe-security-groups \ + --filters="Name=tag:Name,Values=kite-ci" \ + --output json | \ + jq -r ".SecurityGroups[0].GroupId" register: ec2_security_group when: "'rhel' not in test_os" - set_fact: - group_id: "{{ ec2_security_group.security_groups[0].group_id }}" + group_id: "{{ ec2_security_group.stdout }}" when: "'rhel' not in test_os" - name: get virtqe security group - amazon.aws.ec2_security_group_info: - filters: - "tag:Name": "bootc-test" + shell: | + aws ec2 describe-security-groups \ + --filters="Name=tag:Name,Values=bootc-test" \ + --output json | \ + jq -r ".SecurityGroups[0].GroupId" register: ec2_security_group when: "'rhel' in test_os" - set_fact: - group_id: "{{ ec2_security_group.security_groups[0].group_id }}" + group_id: "{{ ec2_security_group.stdout }}" when: "'rhel' in test_os" - name: config ssh keypair used by test - amazon.aws.ec2_key: - name: "kp-bootc-{{ random_num }}" - key_material: "{{ lookup('file', ssh_key_pub) }}" - tags: - name: "bootc-test" + shell: | + aws ec2 import-key-pair \ + --key-name "kp-bootc-{{ random_num }}" \ + --public-key-material "fileb://{{ ssh_key_pub }}" \ + --tag-specification 'ResourceType=key-pair,Tags=[{Key=Name,Value=bootc-test}]' - name: generate ec2_run_instance script template: @@ -124,14 +135,16 @@ instance_json: "{{ result_instance.stdout | from_json }}" - name: wait for instance running - shell: aws ec2 describe-instances --instance-ids {{ instance_json.Instances[0].InstanceId }} --query 'Reservations[0].Instances[0].State.Name' --output text - register: describe_result - retries: 60 - delay: 5 - until: describe_result.stdout == "running" + shell: | + aws ec2 wait instance-running \ + --instance-ids {{ instance_json.Instances[0].InstanceId }} - name: get instance public ip - shell: aws ec2 describe-instances --instance-ids {{ instance_json.Instances[0].InstanceId }} --query 'Reservations[*].Instances[*].PublicIpAddress' --output text + shell: | + aws ec2 describe-instances \ + --instance-ids {{ instance_json.Instances[0].InstanceId }} \ + --query 'Reservations[*].Instances[*].PublicIpAddress' \ + --output text register: ip_result when: "'rhel' not in test_os" @@ -140,7 +153,11 @@ when: "'rhel' not in test_os" - name: get instance private ip - shell: aws ec2 describe-instances --instance-ids {{ instance_json.Instances[0].InstanceId }} --query 'Reservations[*].Instances[*].PrivateIpAddress' --output text + shell: | + aws ec2 describe-instances \ + --instance-ids {{ instance_json.Instances[0].InstanceId }} \ + --query 'Reservations[*].Instances[*].PrivateIpAddress' \ + --output text register: ip_result when: "'rhel' in test_os" diff --git a/playbooks/remove.yaml b/playbooks/remove.yaml index c30f442..5f6cf5a 100644 --- a/playbooks/remove.yaml +++ b/playbooks/remove.yaml @@ -38,31 +38,38 @@ - name: Remove AWS resources block: - name: terminate instance - amazon.aws.ec2_instance: - instance_ids: "{{ instance_id }}" - state: absent - wait: true + shell: | + aws ec2 terminate-instances \ + --instance-ids "{{ instance_id }}" ignore_errors: true - name: wait until instance terminated - amazon.aws.ec2_instance_info: - instance_ids: - - "{{ instance_id }}" - register: result_instance_status - retries: 30 - delay: 10 - until: result_instance_status.instances[0].state.name == "terminated" + shell: | + aws ec2 wait instance-terminated \ + --instance-ids "{{ instance_id }}" - name: remove ec2 key - amazon.aws.ec2_key: - name: "kp-bootc-{{ random_num }}" - state: absent + shell: | + aws ec2 delete-key-pair \ + --key-name "kp-bootc-{{ random_num }}" - name: Deregister AMI (delete associated snapshots too) - amazon.aws.ec2_ami: - image_id: "{{ ami_id }}" - delete_snapshot: true - state: absent + block: + - name: Get snapshot ID + shell: | + aws ec2 describe-images \ + --image-ids "{{ ami_id }}" \ + --query 'Images[0].[BlockDeviceMappings][0][0].Ebs.SnapshotId' \ + --output text + register: snapshot_result + - name: Deregister AMI + shell: | + aws ec2 deregister-image \ + --image-id "{{ ami_id }}" + - name: Delete snapshot + shell: | + aws ec2 delete-snapshot \ + --snapshot-id "{{ snapshot_result.stdout }}" when: ami_id != "" when: platform == "aws" diff --git a/tmt/plans/bib-image.fmf b/tmt/plans/bib-image.fmf index aaf8c73..e0161a3 100644 --- a/tmt/plans/bib-image.fmf +++ b/tmt/plans/bib-image.fmf @@ -13,10 +13,8 @@ prepare: - unzip - how: shell script: | - pip install boto3 botocore openstacksdk - ansible-galaxy collection install openstack.cloud community.general community.libvirt amazon.aws ansible.posix - - how: shell - script: curl "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install + pip install openstacksdk + ansible-galaxy collection install openstack.cloud community.general community.libvirt ansible.posix execute: how: tmt @@ -30,6 +28,9 @@ execute: adjust+: - when: arch != x86_64 and arch != aarch64 enabled: false + prepare+: + - how: shell + script: curl "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install /qcow2: summary: Use bib generate qcow2 image and test locally (nested) @@ -65,6 +66,9 @@ execute: adjust+: - when: arch != x86_64 enabled: false + prepare+: + - how: shell + script: curl -L -o - "https://github.com/vmware/govmomi/releases/latest/download/govc_$(uname -s)_$(uname -m).tar.gz" | sudo tar -C /usr/local/bin -xvzf - govc /iso: summary: Use bib generate ISO image and test locally (nested) diff --git a/tmt/plans/os-replace.fmf b/tmt/plans/os-replace.fmf index 6efb0ed..76d60e8 100644 --- a/tmt/plans/os-replace.fmf +++ b/tmt/plans/os-replace.fmf @@ -13,10 +13,8 @@ prepare: - unzip - how: shell script: | - pip install boto3 botocore openstacksdk - ansible-galaxy collection install openstack.cloud community.general community.libvirt amazon.aws ansible.posix - - how: shell - script: curl "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install + pip install openstacksdk + ansible-galaxy collection install openstack.cloud community.general community.libvirt ansible.posix - how: shell script: curl -kLO ${CERT_URL}/certs/Current-IT-Root-CAs.pem --output-dir /etc/pki/ca-trust/source/anchors && update-ca-trust execute: @@ -57,6 +55,9 @@ execute: adjust+: - when: arch != x86_64 and arch != aarch64 enabled: false + prepare+: + - how: shell + script: curl "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install /azure: summary: Run os-replace test on azure