diff --git a/ol/create_instance.yml b/ol/create_instance.yml index faa3aa7..0606e6a 100644 --- a/ol/create_instance.yml +++ b/ol/create_instance.yml @@ -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 diff --git a/ol/default_vars.yml b/ol/default_vars.yml index 8f055bf..7d24e1f 100644 --- a/ol/default_vars.yml +++ b/ol/default_vars.yml @@ -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" + diff --git a/ol/provision_vbox.yml b/ol/provision_vbox.yml new file mode 100644 index 0000000..7155a2c --- /dev/null +++ b/ol/provision_vbox.yml @@ -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" diff --git a/ol/provision_vnc.yml b/ol/provision_vnc.yml index 3f7d972..85a7a18 100644 --- a/ol/provision_vnc.yml +++ b/ol/provision_vnc.yml @@ -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 @@ -31,10 +31,11 @@ state: link - name: Set vncserver systemd template - ansible.builtin.file: - src: /usr/lib/systemd/system/vncserver@.service - dest: /etc/systemd/system/vncserver@.service - state: link + ansible.builtin.copy: + src: "/usr/lib/systemd/system/vncserver@.service" + dest: "/etc/systemd/system/vncserver@:{{ vnc_port }}.service" + remote_src: true + mode: "0644" - name: Assign username to vnc port ansible.builtin.lineinfile: @@ -52,7 +53,7 @@ ansible.builtin.file: path: /home/{{ username }}/.vnc state: directory - mode: '0700' + mode: "0700" owner: "{{ username }}" group: "{{ username }}" @@ -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 diff --git a/ol/update_all_rpms.yml b/ol/update_all_rpms.yml index d83e466..d10b15b 100644 --- a/ol/update_all_rpms.yml +++ b/ol/update_all_rpms.yml @@ -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