Skip to content

Commit

Permalink
direct ansible deploy
Browse files Browse the repository at this point in the history
fix dir typo

update runs-on value for test-kvm job to use CI-run
  • Loading branch information
viniciusdc committed Mar 6, 2024
1 parent 477cf9f commit 9a92585
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 110 deletions.
7 changes: 7 additions & 0 deletions .github/inventory.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
hpc01-test

[hpc_master]
hpc01-test

[hpc_worker]
hpc01-test
154 changes: 44 additions & 110 deletions .github/workflows/kvm-test.yaml
Original file line number Diff line number Diff line change
@@ -1,111 +1,45 @@
---
name: Vagrant (KVM) Tests

on:
push:
branches:
- "*"
paths:
- "roles/**"
- "tasks/**"
- "tests/**"
- "Vagrantfile"
- ".github/workflows/kvm-test.yaml"

env:
# Prevents Vagrant from creating symlinks
VAGRANT_DISABLE_VBOXSYMLINKCREATE: "1"

jobs:
# https://github.com/jonashackt/vagrant-github-actions
test-kvm:
name: KVM Test
runs-on: "cirun-runner--${{ github.run_id }}"
# runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# - name: Check virtualization support
# run: |
# egrep -c '(vmx|svm)' /proc/cpuinfo
# sudo apt install cpu-checker
# sudo kvm-ok

# https://vagrant-libvirt.github.io/vagrant-libvirt/#installation
- name: Install KVM essentials
run: |
sudo apt update
sudo apt-get install -y qemu libvirt-daemon-system ebtables libguestfs-tools vagrant
sudo adduser $USER libvirt && sudo adduser $USER kvm
- name: Cache Vagrant boxes
uses: actions/cache@v2
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-
- name: Check Libvirt status
run: |
virsh --version
virsh list --all
sudo systemctl status libvirtd
- name: Show Vagrant version
run: vagrant --version

- name: Install vagrant libvirt plugin
run: vagrant plugin install vagrant-libvirt

- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'

- name: Install test dependencies.
run: pip install ansible

- name: Install Ansible Dependencies
working-directory: tests/ubuntu2004-singlenode
run: |
ansible-galaxy collection install community.general
ansible-galaxy collection install ansible.posix
- name: Run vagrant up
working-directory: tests/ubuntu2004-singlenode
run: vagrant up --provider=libvirt

- name: Check Vagrant status
run: |
vagrant status
- name: SSH into Vagrant VM
run: |
vagrant ssh -c "echo 'Hello from Vagrant VM'"
- name: Collect System Info and Metrics for Debugging
if: success()
run: |
vagrant ssh -c "
echo 'System Information:' && uname -a
echo 'Available Disk Space:' && df -h
echo 'Memory Usage:' && free -m
echo 'CPU Information:' && lscpu
echo 'Network Configuration:' && ifconfig
echo 'Firewall Status:' && sudo ufw status
echo 'System Logs:' && journalctl --no-pager | tail -n 100
"
- name: Copy inventory files to .vagrant provider directory
run: |
cp -r inventory.template/* tests/ubuntu2004-singlenode/.vagrant/provisioners/ansible/inventory/
- name: Run vagrant provision
working-directory: tests/ubuntu2004-singlenode
run: vagrant provision

- name: Cleanup
if: always()
run: |
vagrant destroy -f
name: Vagrant (KVM) Tests

on:
pull_request:
push:
branches:
- main

jobs:
test-kvm:
name: KVM Test
runs-on: "cirun-runner--${{ github.run_id }}"
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"

- name: Install dependencies
run: |
pip install ansible
- name: Install Ansible dependencies
run: |
ansible-galaxy collection install -r requirements.yaml
- name: Create deploy folder and move inventory files
run: |
mkdir deploy
cp -r inventory.template/* deploy/
cp .github/inventory.ini deploy/inventory.ini
- name: Update firwall_internal_ip_range
run: |
echo "firewall_internal_ip_range: $(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)" >> deploy/group_vars/all.yaml
- name: Run ansible playbook
run: |
cd deploy
ansible-playbook ../playbook.yaml -i inventory.ini --connection=local -v
env:
ANSIBLE_FORCE_COLOR: True

0 comments on commit 9a92585

Please sign in to comment.