diff --git a/README.md b/README.md index 6503514..3d6175d 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,5 @@ ansible-playbook playbooks/install.yml --ask-become-pass --tags ollama ## To test -- [ ] ollama -- [ ] steam +- [x] ollama +- [x] steam diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..427b65d --- /dev/null +++ b/Vagrantfile @@ -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 \ No newline at end of file diff --git a/ansible.cfg b/ansible.cfg index 3e953c6..f6f6fdc 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,5 +1,4 @@ [defaults] -vault_password_file = .ansible_vault_pass inventory = inventory.ini roles_path = roles host_key_checking = False diff --git a/group_vars/all.yml b/group_vars/all.yml index 909069d..709da08 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -1,6 +1,5 @@ --- ansible_become: true -# ansible_become_pass: "{{ vault_ansible_become_pass }}" timezone: Europe/Paris ansible_user: "{{ lookup('env', 'USER') }}" diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 7cd9777..919bf58 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -13,7 +13,6 @@ group: root mode: '0644' backup: yes - notify: apt update tags: common - name: Mettre à jour le cache APT diff --git a/roles/virtualbox/defaults/main.yml b/roles/virtualbox/defaults/main.yml new file mode 100644 index 0000000..9ba8e52 --- /dev/null +++ b/roles/virtualbox/defaults/main.yml @@ -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" diff --git a/roles/virtualbox/tasks/main.yml b/roles/virtualbox/tasks/main.yml new file mode 100644 index 0000000..64d6374 --- /dev/null +++ b/roles/virtualbox/tasks/main.yml @@ -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 diff --git a/settings.yml b/settings.yml new file mode 100644 index 0000000..58e79bd --- /dev/null +++ b/settings.yml @@ -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 \ No newline at end of file