From 97d6b0ee912dea87e912c31d11dce341a6e606d4 Mon Sep 17 00:00:00 2001 From: Michael DAmato Date: Tue, 28 Nov 2023 12:32:33 -0500 Subject: [PATCH] Fix automated tests --- .github/workflows/rocky8.yml | 21 ++++++++--- .github/workflows/ubuntu20.yml | 38 ++++++++++++++------ roles/rke2_common/tasks/previous_install.yml | 3 ++ 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/.github/workflows/rocky8.yml b/.github/workflows/rocky8.yml index c6aff29e..986e0527 100644 --- a/.github/workflows/rocky8.yml +++ b/.github/workflows/rocky8.yml @@ -1,5 +1,5 @@ --- -name: Rocky 8 +name: Ansible build test for Rocky 8 on: pull_request: @@ -10,7 +10,7 @@ on: jobs: lint-test: - name: Lint + name: Lint for PR runs-on: ubuntu-latest steps: @@ -38,7 +38,7 @@ jobs: run: ansible-lint rocky8-test: - name: Initial build test + name: Ansible build test for Rocky 8 runs-on: ubuntu-latest needs: ['lint-test'] @@ -119,6 +119,10 @@ jobs: echo "" >> ansible.cfg echo "remote_user=centos" >> ansible.cfg echo "private_key_file=.key" >> ansible.cfg + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-gov-west-1 - name: Check hosts.ini and ansible.cfg run: | @@ -160,7 +164,11 @@ jobs: echo "[all:vars]" >> hosts.ini echo "kubernetes_api_server_host=$(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.ini cp hosts.ini inventory/rocky8/hosts.ini - + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-gov-west-1 + - name: Run playbook again with added hosts run: | ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos --verbose --private-key .key site.yml @@ -185,3 +193,8 @@ jobs: run: | cd testing/ terraform destroy -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -auto-approve + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-gov-west-1 + \ No newline at end of file diff --git a/.github/workflows/ubuntu20.yml b/.github/workflows/ubuntu20.yml index 00cabf5f..6adac9e6 100644 --- a/.github/workflows/ubuntu20.yml +++ b/.github/workflows/ubuntu20.yml @@ -1,19 +1,14 @@ --- -name: Ubuntu 20.04 +name: Ansible build test for Ubuntu on: pull_request: workflow_dispatch: -env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: us-gov-west-1 - jobs: lint-test: - name: Lint + name: Lint for PR runs-on: ubuntu-latest steps: @@ -41,7 +36,7 @@ jobs: run: ansible-lint ubuntu20-test: - name: Initial build test + name: Ansible build test for Ubuntu runs-on: ubuntu-latest needs: ['lint-test'] @@ -77,6 +72,10 @@ jobs: cd testing/ terraform plan -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "os=ubuntu20" -no-color continue-on-error: true + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-gov-west-1 - name: Terraform Plan Status if: steps.plan.outcome == 'failure' @@ -86,7 +85,11 @@ jobs: run: | cd testing/ terraform apply -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "os=ubuntu20" -auto-approve - + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-gov-west-1 + - name: Set up Python id: setup_python uses: actions/setup-python@v2 @@ -114,7 +117,11 @@ jobs: echo "" >> ansible.cfg echo "remote_user=ubuntu" >> ansible.cfg echo "private_key_file=.key" >> ansible.cfg - + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-gov-west-1 + - name: Check hosts.ini and ansible.cfg run: | cat hosts.ini @@ -155,7 +162,11 @@ jobs: echo "[all:vars]" >> hosts.ini echo "kubernetes_api_server_host=$(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.ini cp hosts.ini inventory/ubuntu20/hosts.ini - + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-gov-west-1 + - name: Run playbook again with added hosts run: | ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.ini -u ubuntu --verbose --private-key .key site.yml @@ -175,3 +186,8 @@ jobs: run: | cd testing/ terraform destroy -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -auto-approve + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: us-gov-west-1 + \ No newline at end of file diff --git a/roles/rke2_common/tasks/previous_install.yml b/roles/rke2_common/tasks/previous_install.yml index 80df3a00..3466c887 100644 --- a/roles/rke2_common/tasks/previous_install.yml +++ b/roles/rke2_common/tasks/previous_install.yml @@ -40,6 +40,9 @@ args: executable: /usr/bin/bash when: rke2_binary.stat.exists + failed_when: > + (installed_rke2_version_tmp.rc != 141) and + (installed_rke2_version_tmp.rc != 0) - name: Determine if current version differs what what is being installed ansible.builtin.set_fact: