-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvirtualbox.yml
74 lines (63 loc) · 2 KB
/
virtualbox.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
# Virtualbox setup
- name: Install build-esential and dkms (prepare)
apt:
name:
- build-essential
- dkms
- unzip
state: present
update_cache: yes
- name: Add VirtualBox repo keys
apt_key:
url: "https://www.virtualbox.org/download/{{ item }}.asc"
state: present
with_items:
- oracle_vbox
- oracle_vbox_2016
- name: Add VirtualBox repo
apt_repository:
repo: 'deb {{ virtualbox_repo_base_url }}/debian {{ ansible_distribution_release }} contrib'
state: present
update_cache: yes
- name: "Install virtualbox in version {{ virtualbox_version }}"
apt:
name: virtualbox-{{ virtualbox_version }}
state: present
- name: Check if extension pack is already installed
shell: "VBoxManage list extpacks"
register: extpack_list
- name: Output installed extpacks
debug:
var: download_result.stdtout
- name: Download VirtualBox extension pack
get_url:
url: "{{ virtualbox_repo_base_url }}/{{ virtualbox_extpack_version }}/Oracle_VM_VirtualBox_Extension_Pack-{{ virtualbox_extpack_version }}.vbox-extpack"
dest: /tmp/
force: yes
register: download_result
when: 'extpack_list.stdout == "Extension Packs: 0"'
- name: Output downloaded VirtualBox extension pack file name
debug:
var: download_result.dest
verbosity: 1
- name: Install VirtualBox extension pack
shell: "echo 'y' | VBoxManage extpack install --replace {{ download_result.dest }}"
when: 'extpack_list.stdout == "Extension Packs: 0"'
- name: Add user to run virtualbox deamon
user:
name: "{{ virtualbox_user }}"
createhome: yes
shell: '/bin/bash'
state: present
append: yes # append groups
groups: vboxusers
update_password: on_create # only touch PW on user creation
password: "{{ virtualbox_user_pw|password_hash('sha512') }}"
- name: Create a folder for ISO files to be shared with phpVirtualBox
file:
path: /home/{{ virtualbox_user }}/isos
owner: "{{ virtualbox_user }}"
group: vboxusers
mode: 0770
state: directory