Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute Vagrant cluster in CI #57

Merged
merged 7 commits into from
Aug 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CI: Run playbook in Vagrant cluster
  • Loading branch information
sleiner committed Aug 29, 2022
commit e3ee885ef2b15e24ec6de66a18cc33986c8b0aa7
65 changes: 65 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: Test
"on":
pull_request:
push:
branches:
- master

jobs:
vagrant:
name: Vagrant
runs-on: macos-12

env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
VAGRANT_CWD: ${{ github.workspace }}/vagrant

steps:
- name: Check out the codebase
uses: actions/checkout@v2

- name: Install Ansible
run: brew install ansible

- name: Install role dependencies
run: ansible-galaxy install -r collections/requirements.yml

- name: Configure VirtualBox
run: >-
sudo mkdir -p /etc/vbox &&
echo "* 192.168.30.0/24" | sudo tee -a /etc/vbox/networks.conf > /dev/null

- name: Cache Vagrant boxes
uses: actions/cache@v3
with:
path: |
~/.vagrant.d/boxes
key: vagrant-boxes-${{ hashFiles('**/Vagrantfile') }}
restore-keys: |
vagrant-boxes

- name: Create virtual machines
run: vagrant up
timeout-minutes: 10

- name: Provision cluster using Ansible
# Since Ansible sets up _all_ machines, it is sufficient to run it only
# once (i.e, for a single node - we are choosing control1 here)
run: vagrant provision control1 --provision-with ansible
timeout-minutes: 25

- name: Set up kubectl on the host
run: brew install kubectl &&
mkdir -p ~/.kube &&
vagrant ssh control1 --command "cat ~/.kube/config" > ~/.kube/config

- name: Show cluster nodes
run: kubectl describe -A nodes

- name: Show cluster pods
run: kubectl describe -A pods

- name: Destroy virtual machines
if: always() # do this even if a step before has failed
run: vagrant destroy --force