add vagrant for testing + vbox role to test
This commit is contained in:
parent
15c9a59efd
commit
dd227c844e
@ -27,5 +27,5 @@ ansible-playbook playbooks/install.yml --ask-become-pass --tags ollama
|
|||||||
|
|
||||||
## To test
|
## To test
|
||||||
|
|
||||||
- [ ] ollama
|
- [x] ollama
|
||||||
- [ ] steam
|
- [x] steam
|
||||||
|
|||||||
26
Vagrantfile
vendored
Normal file
26
Vagrantfile
vendored
Normal 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
|
||||||
@ -1,5 +1,4 @@
|
|||||||
[defaults]
|
[defaults]
|
||||||
vault_password_file = .ansible_vault_pass
|
|
||||||
inventory = inventory.ini
|
inventory = inventory.ini
|
||||||
roles_path = roles
|
roles_path = roles
|
||||||
host_key_checking = False
|
host_key_checking = False
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
---
|
---
|
||||||
ansible_become: true
|
ansible_become: true
|
||||||
# ansible_become_pass: "{{ vault_ansible_become_pass }}"
|
|
||||||
|
|
||||||
timezone: Europe/Paris
|
timezone: Europe/Paris
|
||||||
ansible_user: "{{ lookup('env', 'USER') }}"
|
ansible_user: "{{ lookup('env', 'USER') }}"
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
backup: yes
|
backup: yes
|
||||||
notify: apt update
|
|
||||||
tags: common
|
tags: common
|
||||||
|
|
||||||
- name: Mettre à jour le cache APT
|
- name: Mettre à jour le cache APT
|
||||||
|
|||||||
5
roles/virtualbox/defaults/main.yml
Normal file
5
roles/virtualbox/defaults/main.yml
Normal 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"
|
||||||
69
roles/virtualbox/tasks/main.yml
Normal file
69
roles/virtualbox/tasks/main.yml
Normal 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
10
settings.yml
Normal 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
|
||||||
Loading…
x
Reference in New Issue
Block a user