From c5f71c9e2e8c96d094ef56ebe1610a21a4681acf Mon Sep 17 00:00:00 2001 From: Timothy Stewart Date: Fri, 26 Jan 2024 22:52:19 -0600 Subject: [PATCH 1/6] fix(ci): fixes for ephemeral nodes --- .github/workflows/test.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8a6362..c1624bc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,31 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} + # these steps are necessary if not using ephemeral nodes + - name: Delete old Vagrant box versions + if: always() # do this even if a step before has failed + run: vagrant box prune --force + + - name: Remove all local Vagrant boxes + if: always() # do this even if a step before has failed + run: vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f + + - name: Remove all Virtualbox VMs + if: always() # do this even if a step before has failed + run: VBoxManage list vms | awk -F'"' '{print $2}' | xargs -I {} VBoxManage unregistervm --delete "{}" + + - name: Remove all Virtualbox HDs + if: always() # do this even if a step before has failed + run: VBoxManage list hdds | awk -F':' '/^UUID:/ {print $2}' | xargs -I {} VBoxManage closemedium disk "{}" --delete + + - name: Remove all Virtualbox Networks + if: always() # do this even if a step before has failed + run: VBoxManage list hostonlyifs | grep '^Name:' | awk '{print $2}' | grep '^vboxnet' | xargs -I {} VBoxManage hostonlyif remove {} + + - name: Remove Virtualbox network config + if: always() # do this even if a step before has failed + run: sudo rm /etc/vbox/networks.conf + - name: Configure VirtualBox run: |- sudo mkdir -p /etc/vbox From ab7ca9b5514585304532128420a8a3c1ca70e520 Mon Sep 17 00:00:00 2001 From: Timothy Stewart Date: Fri, 26 Jan 2024 23:06:02 -0600 Subject: [PATCH 2/6] fix(ci): fixes for ephemeral nodes --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1624bc..94fef42 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,7 @@ jobs: - name: Remove Virtualbox network config if: always() # do this even if a step before has failed - run: sudo rm /etc/vbox/networks.conf + run: sudo rm /etc/vbox/networks.conf || true - name: Configure VirtualBox run: |- @@ -112,7 +112,7 @@ jobs: - name: Remove Virtualbox network config if: always() # do this even if a step before has failed - run: sudo rm /etc/vbox/networks.conf + run: sudo rm /etc/vbox/networks.conf || true - name: Upload log files if: always() # do this even if a step before has failed From de26a79a4c8c9f2cf75a772013e7f97053a2fb58 Mon Sep 17 00:00:00 2001 From: Timothy Stewart Date: Fri, 26 Jan 2024 23:09:30 -0600 Subject: [PATCH 3/6] fix(ci): fixes for ephemeral nodes --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 94fef42..f613f89 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: - name: Remove all local Vagrant boxes if: always() # do this even if a step before has failed - run: vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f + run: if vagrant box list &> /dev/null; then vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f; echo "All Vagrant boxes removed."; else echo "No Vagrant boxes found."; fi - name: Remove all Virtualbox VMs if: always() # do this even if a step before has failed @@ -96,7 +96,7 @@ jobs: - name: Remove all local Vagrant boxes if: always() # do this even if a step before has failed - run: vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f + run: if vagrant box list &> /dev/null; then vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f; echo "All Vagrant boxes removed."; else echo "No Vagrant boxes found."; fi - name: Remove all Virtualbox VMs if: always() # do this even if a step before has failed From 98ef696f31952cea7ab29be20a0443e460f65b9c Mon Sep 17 00:00:00 2001 From: Timothy Stewart Date: Fri, 26 Jan 2024 23:12:50 -0600 Subject: [PATCH 4/6] fix(ci): fixes for ephemeral nodes --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f613f89..1fc10b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: - name: Remove all local Vagrant boxes if: always() # do this even if a step before has failed - run: if vagrant box list &> /dev/null; then vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f; echo "All Vagrant boxes removed."; else echo "No Vagrant boxes found."; fi + run: if vagrant box list 2>/dev/null; then vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f 2>/dev/null && echo "All Vagrant boxes removed." || echo "No Vagrant boxes found."; else echo "No Vagrant boxes found."; fi - name: Remove all Virtualbox VMs if: always() # do this even if a step before has failed @@ -96,7 +96,7 @@ jobs: - name: Remove all local Vagrant boxes if: always() # do this even if a step before has failed - run: if vagrant box list &> /dev/null; then vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f; echo "All Vagrant boxes removed."; else echo "No Vagrant boxes found."; fi + run: if vagrant box list 2>/dev/null; then vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f 2>/dev/null && echo "All Vagrant boxes removed." || echo "No Vagrant boxes found."; else echo "No Vagrant boxes found."; fi - name: Remove all Virtualbox VMs if: always() # do this even if a step before has failed From 3888a29bb11f7568797d8b1c2a1f7d4a11b461d5 Mon Sep 17 00:00:00 2001 From: Techno Tim Date: Sat, 27 Jan 2024 15:35:47 -0600 Subject: [PATCH 5/6] fix(ci): only run CI for PRs (#430) * fix(ci): only run CI for PRs * fix(ci): ensure that branch is up to date * fix(ci): ensure that branch is up to date --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77f9333..c47ece0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: "CI" on: pull_request: - push: - branches: - - master + types: + - opened + - synchronize paths-ignore: - '**/README.md' jobs: From 3f06a11c8d729258bed5b476015a621aeac26802 Mon Sep 17 00:00:00 2001 From: Gereon Vey Date: Sat, 27 Jan 2024 23:30:13 +0100 Subject: [PATCH 6/6] fetch kubeconfig from master after deployment (#431) Co-authored-by: Techno Tim --- .gitignore | 1 + site.yml | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 78f3d0b..89c5d4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .env/ *.log ansible.cfg +kubeconfig diff --git a/site.yml b/site.yml index 2aa46e7..e57deab 100644 --- a/site.yml +++ b/site.yml @@ -46,3 +46,14 @@ roles: - role: k3s_server_post become: true + +- name: Storing kubeconfig in the playbook directory + hosts: master + environment: "{{ proxy_env | default({}) }}" + tasks: + - name: Copying kubeconfig from {{ hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname'] }} + ansible.builtin.fetch: + src: "{{ ansible_user_dir }}/.kube/config" + dest: ./kubeconfig + flat: true + when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']