From 32f2826d84b25ed9581c924aded7369e919b5d2b Mon Sep 17 00:00:00 2001 From: greg pereira Date: Wed, 1 May 2024 20:48:16 -0700 Subject: [PATCH] check access to ilab Signed-off-by: greg pereira --- .github/workflows/training-e2e.yaml | 17 +++++++++++----- training/Makefile | 1 + training/provision/playbook.yml | 31 +++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/.github/workflows/training-e2e.yaml b/.github/workflows/training-e2e.yaml index 313072485..466ac5c00 100644 --- a/.github/workflows/training-e2e.yaml +++ b/.github/workflows/training-e2e.yaml @@ -17,7 +17,7 @@ env: TF_VAR_aws_region: "eu-west-2" TF_VAR_aws_ami_owners: '["125523088429"]' TF_VAR_aws_ami_name: '["Fedora-Cloud-Base-*"]' - TF_VAR_aws_volume_size: 128 + TF_VAR_aws_volume_size: 500 TF_VAR_aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} TF_VAR_aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -74,6 +74,7 @@ jobs: run: | echo "id=$(terraform output id | xargs)" >> $GITHUB_OUTPUT echo "url=$(terraform output host | xargs)" >> $GITHUB_OUTPUT + echo "ssh_public_key=$(terraform output ssh_public_key | xargs)" >> $GITHUB_OUTPUT echo "pem_filename=$(terraform output pem_filename | xargs)" >> $GITHUB_OUTPUT working-directory: terraform-test-environment-module @@ -83,16 +84,22 @@ jobs: - name: Provision run: | - ansible-playbook ./main/training/provision/playbook.yml \ + ssh_public_key=$(printf '%s\n' "${{ steps.terraform-output.outputs.ssh_public_key }}" | sed -e 's/[\/&]/\\&/g') + ansible-playbook ./main/training/provision/playbook.yml -vvv \ -i terraform-test-environment-module/hosts.ini \ --private-key=terraform-test-environment-module/${{ steps.terraform-output.outputs.pem_filename }} \ - --extra-vars "image_name=${{ matrix.image_name }}" + --extra-vars "image_name=${{ matrix.image_name }}" \ + --extra-vars "ssh_public_key=$ssh_public_key" \ + --extra-vars "registry_user=${{ secrets.REGISTRY_USER }}" \ + --extra-vars "registry_password=${{ secrets.REGISTRY_PASSWORD }}" env: ANSIBLE_HOST_KEY_CHECKING: false - - name: log some networking information + - name: run the e2e tests run: | - ifconfig + ssh -i terraform-test-environment-module/${{ steps.terraform-output.outputs.pem_filename }} \ + ${{ steps.terraform-output.outputs.url }} \ + curl -sLO /tmp https://raw.githubusercontent.com/stefwalter/instructlab/container-testing/scripts/basic-workflow-tests.sh - name: Destroy Test Environment id: down diff --git a/training/Makefile b/training/Makefile index ae4a7715f..12e1d4258 100644 --- a/training/Makefile +++ b/training/Makefile @@ -90,5 +90,6 @@ prune: buildah rm --all podman image prune -f +.PHONY: clean clean: rm -rf build diff --git a/training/provision/playbook.yml b/training/provision/playbook.yml index 566afc6df..1b5c411ce 100644 --- a/training/provision/playbook.yml +++ b/training/provision/playbook.yml @@ -15,16 +15,43 @@ - name: Gather facts for first time ansible.builtin.setup: + - name: Get size of root filesystem + ansible.builtin.shell: + cmd: df -h / + register: root_fs_size + + - name: Log size of root filesystem + ansible.builtin.debug: + msg: "Size of root filesystem: {{ root_fs_size.stdout }}" + - name: Check Podman Present ansible.builtin.package: name: podman state: present + - name: Login to default registry and create ${XDG_RUNTIME_DIR}/containers/auth.json + containers.podman.podman_login: + username: "{{ registry_user }}" + password: "{{ registry_password }}" + registry: quay.io + + - name: Building an image with ssh key + containers.podman.podman_container: + name: localhost/temp_image + image: "quay.io/ai-lab/{{ image_name }}:latest" + command: + - mkdir /usr/etc-system + - test -n "{{ ssh_public_key }}" + - echo 'AuthorizedKeysFile /usr/etc-system/%u.keys' >> /etc/ssh/sshd_config.d/30-auth-system.conf + - "echo {{ ssh_public_key }} > /usr/etc-system/fedora.keys && chmod 0600 /usr/etc-system/fedora.keys" + state: present + recreate: true + - name: Bootc install ignore_unreachable: true containers.podman.podman_container: name: "{{ image_name }}" - image: "quay.io/ai-lab/{{ image_name }}:latest" + image: localhost/temp_image state: started auto_remove: yes cap_add: @@ -40,4 +67,4 @@ - name: Restart instance ansible.builtin.reboot: - test_command: pwd + test_command: which ilab