Skip to content

Commit

Permalink
Move VirtualBox-related stuff to its own role.
Browse files Browse the repository at this point in the history
  • Loading branch information
damiendart committed Jan 24, 2024
1 parent 0951af0 commit d107a63
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 42 deletions.
1 change: 1 addition & 0 deletions playbook-provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- 'rust'
- 'syncthing'
- 'tailscale'
- 'virtualbox'
- 'webserver'
vars:
webserver__vhosts_cleanup: '{{ cli__website_cleanup | default(False) }}'
Expand Down
1 change: 0 additions & 1 deletion roles/development/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ development__obsidian_version: '1.4.16'
development__projects_folder: 'Shed'
development__run_gui_tasks: false
development__update_dotfiles: false
development__virtualbox_version: '7.0'


# The following variables will have host-specific and/or sensitive
Expand Down
3 changes: 0 additions & 3 deletions roles/development/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,5 @@
ansible.builtin.include_tasks: 'gui.yml'
when: development__run_gui_tasks | bool

- name: 'Include VirtualBox installation tasks'
ansible.builtin.include_tasks: 'virtualbox.yml'

- name: 'Include Open VM Tools installation tasks'
ansible.builtin.include_tasks: 'open-vm-tools.yml'
35 changes: 0 additions & 35 deletions roles/development/tasks/virtualbox.yml

This file was deleted.

7 changes: 7 additions & 0 deletions roles/virtualbox/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was written by Damien Dart, <[email protected]>. This is
# free and unencumbered software released into the public domain. For
# more information, please refer to the accompanying "UNLICENCE" file.

---
virtualbox__vboxusers_users: []
virtualbox__virtualbox_version: '7.0'
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
- name: 'Notify user about "vboxusers" group membership update'
ansible.builtin.debug:
msg: >-
If the administrator user is currently logged in, you will need to
log out and log back in for the "vboxusers" group membership to
take effect.
If any users are currently logged in, you will need to log out and
log back in for the "vboxusers" group membership to take effect.
6 changes: 6 additions & 0 deletions roles/virtualbox/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file was written by Damien Dart, <[email protected]>. This is
# free and unencumbered software released into the public domain. For
# more information, please refer to the accompanying "UNLICENCE" file.

---
dependencies: []
33 changes: 33 additions & 0 deletions roles/virtualbox/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Installs VirtualBox.
#
# This file was written by Damien Dart, <[email protected]>. This is
# free and unencumbered software released into the public domain. For
# more information, please refer to the accompanying "UNLICENCE" file.

---
- name: 'Ensure the VirtualBox package signing key is present for APT'
ansible.builtin.apt_key:
state: 'present'
url: 'https://www.virtualbox.org/download/oracle_vbox_2016.asc'

- name: 'Ensure the VirtualBox repository is present in APT sources list'
ansible.builtin.apt_repository:
repo: 'deb http://download.virtualbox.org/virtualbox/debian {{ ansible_distribution_release }} contrib'
state: 'present'

- name: 'Ensure VirtualBox is installed'
ansible.builtin.apt:
force_apt_get: true
name: 'virtualbox-{{ virtualbox__virtualbox_version }}'
state: 'present'

# To access USB devices from VirtualBox guests, the host user must
# be a member of the "vboxusers" group. For more information, see
# <https://www.virtualbox.org/manual/ch02.html#install-linux-vboxusers>.
- name: 'Ensure specified users have access to USB devices in VirtualBox'
ansible.builtin.user:
name: '{{ item }}'
groups: 'vboxusers'
append: true
loop: '{{ [virtualbox__vboxusers_users] | flatten }}'
notify: 'Notify user about "vboxusers" group membership update'

0 comments on commit d107a63

Please sign in to comment.