From 398b22bd960e2bf79a803b4cd83e15d224fc4758 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sun, 16 Apr 2023 22:20:07 +0100 Subject: [PATCH] test(vagrant): add Vagrantfile to use the tests VM. --- tests/Vagrantfile | 57 +++++++++++++++++++++++++++++++++++++++++++++++ tests/boxes.yml | 28 +++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 tests/Vagrantfile create mode 100644 tests/boxes.yml diff --git a/tests/Vagrantfile b/tests/Vagrantfile new file mode 100644 index 00000000..78e3b6bb --- /dev/null +++ b/tests/Vagrantfile @@ -0,0 +1,57 @@ +# -*- mode: ruby -*- +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2023 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +require 'yaml' + +machines = YAML.load_file(File.join(File.dirname(__FILE__), 'boxes.yml')) + +Vagrant.require_version '>= 2.0.0' + +Vagrant.configure("2") do |config| + + config.ssh.keys_only = true + config.ssh.insert_key = false + config.ssh.private_key_path = [ '~/.ssh/id_ed25519' ] + config.ssh.username = 'user' + + machines['boxes'].each do |instance| + + # Configure the VMs per details in boxes.yml + config.vm.define instance['name'] do |srv| + srv.vm.box = instance['box'] + srv.vm.box_check_update = false + srv.vm.post_up_message = instance.to_yaml + srv.vm.synced_folder '../', '/home/user/Projects/apparmor.d', type: 'virtiofs' + + # Configure Libvirt provider + srv.vm.provider 'libvirt' do |libvirt| + libvirt.driver = 'kvm' + libvirt.connect_via_ssh = false + libvirt.storage_pool_name = 'default' + libvirt.memory = instance['ram'] + libvirt.cpus = instance['cpu'] + libvirt.cpu_mode = 'host-passthrough' + libvirt.machine_type = 'q35' + libvirt.video_type = 'virtio' + libvirt.graphics_type = 'spice' + libvirt.sound_type = 'ich9' + libvirt.tpm_model = 'tpm-crb' + libvirt.tpm_type = 'emulator' + libvirt.tpm_version = '2.0' + libvirt.random model: 'random' + libvirt.memorybacking 'source', type: 'memfd' + libvirt.memorybacking 'access', mode: 'shared' + libvirt.channel type: 'unix', target_name: 'org.qemu.guest_agent.0', target_type: 'virtio' + (1..2).each do + libvirt.redirdev :type => "spicevmc" + end + if instance['uefi'] + libvirt.loader = '/usr/share/edk2-ovmf/x64/OVMF_CODE.fd' + end + end + + end + end +end diff --git a/tests/boxes.yml b/tests/boxes.yml new file mode 100644 index 00000000..b8501d5e --- /dev/null +++ b/tests/boxes.yml @@ -0,0 +1,28 @@ +--- + +boxes: + + - name: arch-gnome + box: aa-archlinux-gnome + uefi: false + ram: '6144' + cpu: '6' + + - name: arch-kde + box: aa-archlinux-kde + uefi: false + ram: '6144' + cpu: '6' + + - name: ubuntu-server + box: aa-ubuntu-server + uefi: true + ram: '6144' + cpu: '6' + + - name: opensuse-kde + box: aa-opensuse-kde + uefi: true + ram: '6144' + cpu: '6' +