Skip to content

Commit dabac4b

Browse files
authored
Merge pull request #35 from bgraef/main
add use-vbox code for ol
2 parents 6c20338 + d046123 commit dabac4b

File tree

5 files changed

+125
-11
lines changed

5 files changed

+125
-11
lines changed

ol/create_instance.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@
315315
ansible.builtin.import_playbook: provision_vnc.yml
316316
when: use_vnc
317317

318+
- name: Provision VirtualBox
319+
ansible.builtin.import_playbook: provision_vbox.yml
320+
when: use_vbox
321+
318322
- name: Print instances
319323
hosts: all
320324
become: true

ol/default_vars.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,10 @@ use_haproxy: false
4545
use_nginx: false
4646
use_nfs: false
4747
use_quay_ha: false
48+
49+
use_vbox: false
50+
virtualbox_version: "7.1"
51+
virtualbox_extpack_version: "7.1.2"
52+
ol_iso_version: "9"
53+
ol_update: "4"
54+

ol/provision_vbox.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
# Copyright (c) 2024 Oracle and/or its affiliates.
3+
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
4+
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
5+
# See LICENSE.TXT for details.
6+
7+
- name: Install VNC Server and GNOME Desktop
8+
hosts: vbox
9+
vars_files:
10+
- default_vars.yml
11+
become: true
12+
13+
tasks:
14+
15+
- name: Install ol8_developer_EPEL
16+
ansible.builtin.dnf:
17+
name: oracle-epel-release-el8
18+
state: present
19+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
20+
21+
- name: Enable ol8_developer_EPEL repo
22+
ansible.builtin.command:
23+
cmd: dnf config-manager --enable ol8_developer_EPEL
24+
register: dnf_result
25+
changed_when: dnf_result.rc == 0
26+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
27+
28+
- name: Install required packages for virtualbox
29+
ansible.builtin.dnf:
30+
name:
31+
- "kernel-uek-devel-{{ ansible_kernel }}"
32+
- gcc
33+
- make
34+
- perl
35+
- xcb-util-cursor
36+
state: present
37+
38+
- name: Add virtualbox repo keys
39+
ansible.builtin.rpm_key:
40+
state: present
41+
key: https://www.virtualbox.org/download/oracle_vbox_2016.asc
42+
43+
- name: Add virtualbox repo
44+
ansible.builtin.yum_repository:
45+
name: virtualbox
46+
description: Oracle VirtualBox
47+
baseurl: http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch
48+
49+
- name: "Install virtualbox version {{ virtualbox_version }}"
50+
ansible.builtin.dnf:
51+
name: "VirtualBox-{{ virtualbox_version }}"
52+
state: present
53+
54+
- name: Check if extension pack is already installed
55+
ansible.builtin.shell: |
56+
vboxmanage list extpacks
57+
register: extpack_list
58+
changed_when: extpack_list.rc != 0
59+
60+
- name: Output installed extpacks
61+
ansible.builtin.debug:
62+
var: extpack_list.stdout
63+
verbosity: 1
64+
65+
- name: Download virtualbox extension pack
66+
ansible.builtin.get_url:
67+
url: "{{ base_url }}/{{ virtualbox_extpack_version }}/Oracle_VirtualBox_Extension_Pack-{{ virtualbox_extpack_version }}.vbox-extpack"
68+
dest: /tmp/
69+
force: true
70+
mode: "0644"
71+
register: download_result
72+
when: 'extpack_list.stdout == "Extension Packs: 0"'
73+
vars:
74+
base_url: "https://download.virtualbox.org/virtualbox"
75+
76+
- name: Output download virtualbox extension pack file name
77+
ansible.builtin.debug:
78+
var: download_result.dest
79+
verbosity: 1
80+
81+
- name: Install virtualbox extension pack
82+
ansible.builtin.shell:
83+
cmd: |
84+
set -o pipefail
85+
echo 'y' | vboxmanage extpack install --replace {{ download_result.dest }}
86+
executable: /bin/bash
87+
register: install_extpack
88+
changed_when: install_extpack != 0
89+
when: 'extpack_list.stdout == "Extension Packs: 0"'
90+
91+
- name: Download the Oracle Linux iso file
92+
ansible.builtin.get_url:
93+
url: "{{ base_url }}/OL{{ ol_iso_version }}/u{{ ol_update }}/x86_64/OracleLinux-R{{ ol_iso_version }}-U{{ ol_update }}-x86_64-dvd.iso"
94+
dest: /home/{{ username }}
95+
force: true
96+
mode: "0644"
97+
register: download_iso_result
98+
until: "'OK' in download_iso_result.msg"
99+
retries: 5
100+
delay: 10
101+
vars:
102+
base_url: "https://yum.oracle.com/ISOS/OracleLinux"

ol/provision_vnc.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
55
# See LICENSE.TXT for details.
66

7-
- name: Install Podman and Container Tools
8-
hosts: server
7+
- name: Install VNC Server and GNOME Desktop
8+
hosts: server,vbox
99
vars_files:
1010
- default_vars.yml
1111
become: true
@@ -31,10 +31,11 @@
3131
state: link
3232

3333
- name: Set vncserver systemd template
34-
ansible.builtin.file:
35-
src: /usr/lib/systemd/system/[email protected]
36-
dest: /etc/systemd/system/[email protected]
37-
state: link
34+
ansible.builtin.copy:
35+
src: "/usr/lib/systemd/system/[email protected]"
36+
dest: "/etc/systemd/system/vncserver@:{{ vnc_port }}.service"
37+
remote_src: true
38+
mode: "0644"
3839

3940
- name: Assign username to vnc port
4041
ansible.builtin.lineinfile:
@@ -52,7 +53,7 @@
5253
ansible.builtin.file:
5354
path: /home/{{ username }}/.vnc
5455
state: directory
55-
mode: '0700'
56+
mode: "0700"
5657
owner: "{{ username }}"
5758
group: "{{ username }}"
5859

@@ -70,11 +71,11 @@
7071
path: "/home/{{ username }}/.vnc/passwd"
7172
owner: "{{ username }}"
7273
group: "{{ usergroup }}"
73-
mode: '0600'
74+
mode: "0600"
7475

7576
- name: Start and enable the vnc service
7677
ansible.builtin.systemd:
77-
state: started
78+
name: "vncserver@:{{ vnc_port }}.service"
7879
daemon_reload: true
79-
name: vncserver@:{{ vnc_port }}.service
8080
enabled: true
81+
state: started

ol/update_all_rpms.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# See LICENSE.TXT for details.
66

77
- name: Install latest Oracle Linux packages
8-
hosts: server
8+
hosts: server,vbox
99
vars_files:
1010
- default_vars.yml
1111
become: true

0 commit comments

Comments
 (0)