|
| 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" |
0 commit comments