Skip to content

Commit

Permalink
Merge pull request #35 from bgraef/main
Browse files Browse the repository at this point in the history
add use-vbox code for ol
  • Loading branch information
bgraef authored Sep 28, 2024
2 parents 6c20338 + d046123 commit dabac4b
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 11 deletions.
4 changes: 4 additions & 0 deletions ol/create_instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@
ansible.builtin.import_playbook: provision_vnc.yml
when: use_vnc

- name: Provision VirtualBox
ansible.builtin.import_playbook: provision_vbox.yml
when: use_vbox

- name: Print instances
hosts: all
become: true
Expand Down
7 changes: 7 additions & 0 deletions ol/default_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ use_haproxy: false
use_nginx: false
use_nfs: false
use_quay_ha: false

use_vbox: false
virtualbox_version: "7.1"
virtualbox_extpack_version: "7.1.2"
ol_iso_version: "9"
ol_update: "4"

102 changes: 102 additions & 0 deletions ol/provision_vbox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
# Copyright (c) 2024 Oracle and/or its affiliates.
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
# See LICENSE.TXT for details.

- name: Install VNC Server and GNOME Desktop
hosts: vbox
vars_files:
- default_vars.yml
become: true

tasks:

- name: Install ol8_developer_EPEL
ansible.builtin.dnf:
name: oracle-epel-release-el8
state: present
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Enable ol8_developer_EPEL repo
ansible.builtin.command:
cmd: dnf config-manager --enable ol8_developer_EPEL
register: dnf_result
changed_when: dnf_result.rc == 0
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Install required packages for virtualbox
ansible.builtin.dnf:
name:
- "kernel-uek-devel-{{ ansible_kernel }}"
- gcc
- make
- perl
- xcb-util-cursor
state: present

- name: Add virtualbox repo keys
ansible.builtin.rpm_key:
state: present
key: https://www.virtualbox.org/download/oracle_vbox_2016.asc

- name: Add virtualbox repo
ansible.builtin.yum_repository:
name: virtualbox
description: Oracle VirtualBox
baseurl: http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch

- name: "Install virtualbox version {{ virtualbox_version }}"
ansible.builtin.dnf:
name: "VirtualBox-{{ virtualbox_version }}"
state: present

- name: Check if extension pack is already installed
ansible.builtin.shell: |
vboxmanage list extpacks
register: extpack_list
changed_when: extpack_list.rc != 0

- name: Output installed extpacks
ansible.builtin.debug:
var: extpack_list.stdout
verbosity: 1

- name: Download virtualbox extension pack
ansible.builtin.get_url:
url: "{{ base_url }}/{{ virtualbox_extpack_version }}/Oracle_VirtualBox_Extension_Pack-{{ virtualbox_extpack_version }}.vbox-extpack"
dest: /tmp/
force: true
mode: "0644"
register: download_result
when: 'extpack_list.stdout == "Extension Packs: 0"'
vars:
base_url: "https://download.virtualbox.org/virtualbox"

- name: Output download virtualbox extension pack file name
ansible.builtin.debug:
var: download_result.dest
verbosity: 1

- name: Install virtualbox extension pack
ansible.builtin.shell:
cmd: |
set -o pipefail
echo 'y' | vboxmanage extpack install --replace {{ download_result.dest }}
executable: /bin/bash
register: install_extpack
changed_when: install_extpack != 0
when: 'extpack_list.stdout == "Extension Packs: 0"'

- name: Download the Oracle Linux iso file
ansible.builtin.get_url:
url: "{{ base_url }}/OL{{ ol_iso_version }}/u{{ ol_update }}/x86_64/OracleLinux-R{{ ol_iso_version }}-U{{ ol_update }}-x86_64-dvd.iso"
dest: /home/{{ username }}
force: true
mode: "0644"
register: download_iso_result
until: "'OK' in download_iso_result.msg"
retries: 5
delay: 10
vars:
base_url: "https://yum.oracle.com/ISOS/OracleLinux"
21 changes: 11 additions & 10 deletions ol/provision_vnc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
# See LICENSE.TXT for details.

- name: Install Podman and Container Tools
hosts: server
- name: Install VNC Server and GNOME Desktop
hosts: server,vbox
vars_files:
- default_vars.yml
become: true
Expand All @@ -31,10 +31,11 @@
state: link

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

- name: Assign username to vnc port
ansible.builtin.lineinfile:
Expand All @@ -52,7 +53,7 @@
ansible.builtin.file:
path: /home/{{ username }}/.vnc
state: directory
mode: '0700'
mode: "0700"
owner: "{{ username }}"
group: "{{ username }}"

Expand All @@ -70,11 +71,11 @@
path: "/home/{{ username }}/.vnc/passwd"
owner: "{{ username }}"
group: "{{ usergroup }}"
mode: '0600'
mode: "0600"

- name: Start and enable the vnc service
ansible.builtin.systemd:
state: started
name: "vncserver@:{{ vnc_port }}.service"
daemon_reload: true
name: vncserver@:{{ vnc_port }}.service
enabled: true
state: started
2 changes: 1 addition & 1 deletion ol/update_all_rpms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# See LICENSE.TXT for details.

- name: Install latest Oracle Linux packages
hosts: server
hosts: server,vbox
vars_files:
- default_vars.yml
become: true
Expand Down

0 comments on commit dabac4b

Please sign in to comment.