add vagrant for testing + vbox role to test

This commit is contained in:
Grégory Lebreton 2026-01-19 15:18:26 +01:00
parent 15c9a59efd
commit dd227c844e
8 changed files with 112 additions and 5 deletions

View File

@ -27,5 +27,5 @@ ansible-playbook playbooks/install.yml --ask-become-pass --tags ollama
## To test
- [ ] ollama
- [ ] steam
- [x] ollama
- [x] steam

26
Vagrantfile vendored Normal file
View File

@ -0,0 +1,26 @@
require 'yaml'
settings = YAML.load_file('settings.yml')
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
settings['vms'].each do |vm|
config.vm.define vm['name'] do |node|
node.vm.box = vm['os']
node.vm.hostname = vm['hostname']
node.vm.network :private_network, ip: vm['ip']
# provider
config.vm.provider settings['provider']['type'].to_sym do |v|
v.memory = vm['memory']
# Provisioning configuration for Ansible.
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbooks/install.yml"
end
end
end
end
end

View File

@ -1,5 +1,4 @@
[defaults]
vault_password_file = .ansible_vault_pass
inventory = inventory.ini
roles_path = roles
host_key_checking = False

View File

@ -1,6 +1,5 @@
---
ansible_become: true
# ansible_become_pass: "{{ vault_ansible_become_pass }}"
timezone: Europe/Paris
ansible_user: "{{ lookup('env', 'USER') }}"

View File

@ -13,7 +13,6 @@
group: root
mode: '0644'
backup: yes
notify: apt update
tags: common
- name: Mettre à jour le cache APT

View File

@ -0,0 +1,5 @@
---
virtualbox_version: "7.0"
virtualbox_package: "virtualbox-{{ virtualbox_version }}"
virtualbox_repo_key_url: "https://www.virtualbox.org/download/oracle_vbox_2016.asc"
virtualbox_repo_url: "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian trixie contrib"

View File

@ -0,0 +1,69 @@
---
- name: Install prerequisites
apt:
name:
- apt-transport-https
- ca-certificates
- gnupg
- lsb-release
- dkms
- build-essential
state: present
update_cache: yes
- name: Disable KVM modules if present
block:
- name: Check if kvm modules are loaded
shell: |
lsmod | grep -E 'kvm_intel|kvm_amd|kvm' || true
register: kvm_modules
changed_when: false
- name: Blacklist KVM modules
copy:
dest: /etc/modprobe.d/disable-kvm.conf
content: |
# Disabled for VirtualBox compatibility
blacklist kvm
blacklist kvm_intel
blacklist kvm_amd
when: kvm_modules.stdout != ""
- name: Remove loaded KVM modules immediately
shell: |
rmmod kvm_intel || true
rmmod kvm_amd || true
rmmod kvm || true
when: kvm_modules.stdout != ""
ignore_errors: yes
- name: Add VirtualBox repository GPG key
ansible.builtin.apt_key:
url: "{{ virtualbox_repo_key_url }}"
state: present
- name: Add VirtualBox apt repository
ansible.builtin.apt_repository:
repo: "{{ virtualbox_repo_url }}"
state: present
filename: "virtualbox"
- name: Update apt cache
apt:
update_cache: yes
- name: Install VirtualBox
apt:
name: "{{ virtualbox_package }}"
state: present
- name: Ensure vboxdrv is loaded
command: /sbin/vboxconfig
register: vboxconfig
changed_when: "'done' in vboxconfig.stdout"
- name: Add user to vboxusers group
user:
name: "{{ ansible_user }}"
groups: vboxusers
append: yes

10
settings.yml Normal file
View File

@ -0,0 +1,10 @@
vms:
- name: "server-1"
hostname: "server-1"
ip: "192.168.60.2"
memory: 1024
os: "trixie"
provider:
type: "virtualbox"
# linked_clone: false