-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplaybook-virtualbox.yml
74 lines (62 loc) · 2 KB
/
playbook-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
---
- hosts: all
become: true
vars:
packages_to_install: [ 'kernel', 'kernel-headers', 'rubygems', '@development', 'gcc-c++', 'libvirt', 'libvirt-devel', 'ruby-devel', 'elfutils-libelf-devel', 'epel-release']
vagrant_plugins: ['vagrant-scp']
vagrant_rpm_url: 'https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.rpm'
virtualbox_rpm_url: 'https://download.virtualbox.org/virtualbox/6.1.8/VirtualBox-6.1-6.1.8_137981_el8-1.x86_64.rpm'
tasks:
- name: Update the whole system
yum:
name: '*'
state: latest
register: update_packages
- name: reboot after update
reboot:
when: update_packages.changed
- name: Wait for system to boot up
wait_for:
port: 22
delay: 15
timeout: 100
when: update_packages.changed
- name: Install packages additional packages
yum:
name: "{{packages_to_install}}"
state: present
- name: Install vagrant
yum:
name: "{{vagrant_rpm_url}}"
state: present
- name: Install Virtualbox
yum:
name: "{{virtualbox_rpm_url}}"
state: present
register: virtbox_installed
- name: Start and enable vboxdrv
service:
name: vboxdrv
state: started
enabled: true
- name: Install vagrant plugins
command: "vagrant plugin install {{item}}"
loop: "{{vagrant_plugins}}"
- name: Install bats
yum:
name: "https://download.opensuse.org/repositories/home:/alex_baranowski/CentOS_8/noarch/bats-1.1.0-4.1.noarch.rpm"
state: present
- name: reboot machine if VirtualBox was installed
reboot:
when: virtbox_installed.changed
- name: add vagrant user to vboxusers gropu
user:
groups: [ 'vboxusers' ]
append: yes
user: vagrant
- name: Wait for system to boot up if VirtualBox was installed
wait_for:
port: 22
delay: 15
timeout: 100
when: virtbox_installed.changed