|
| 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 required packages for virtualbox |
| 16 | + ansible.builtin.dnf: |
| 17 | + name: |
| 18 | + - "kernel-uek-devel-{{ ansible_kernel }}" |
| 19 | + - gcc |
| 20 | + - make |
| 21 | + - perl |
| 22 | + state: latest |
| 23 | + |
| 24 | + - name: Add virtualbox repo keys |
| 25 | + ansible.builtin.rpm_key: |
| 26 | + state: present |
| 27 | + key: https://www.virtualbox.org/download/oracle_vbox_2016.asc |
| 28 | + |
| 29 | + - name: Add virtualbox repo |
| 30 | + ansible.builtin.yum_repository: |
| 31 | + name: virtualbox |
| 32 | + description: Oracle VirtualBox |
| 33 | + baseurl: http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch |
| 34 | + |
| 35 | + - name: "Install virtualbox version {{ virtualbox_version }}" |
| 36 | + ansible.builtin.dnf: |
| 37 | + name: "VirtualBox-{{ virtualbox_version }}" |
| 38 | + state: latest |
| 39 | + |
| 40 | + - name: Check if extension pack is already installed |
| 41 | + ansible.builtin.shell: "vboxmanage list extpacks" |
| 42 | + register: extpack_list |
| 43 | + |
| 44 | + - name: Output installed extpacks |
| 45 | + ansible.builtin.debug: |
| 46 | + var: extpack_list.stdout |
| 47 | + verbosity: 1 |
| 48 | + |
| 49 | + - name: Download virtualbox extension pack |
| 50 | + ansible.builtin.get_url: |
| 51 | + url: 'https://download.virtualbox.org/virtualbox/{{ virtualbox_extpack_version }}/Oracle_VirtualBox_Extension_Pack-{{ virtualbox_extpack_version }}.vbox-extpack' |
| 52 | + dest: /tmp/ |
| 53 | + force: yes |
| 54 | + register: download_result |
| 55 | + when: 'extpack_list.stdout == "Extension Packs: 0"' |
| 56 | + |
| 57 | + - name: Output download virtualbox extension pack file name |
| 58 | + ansible.builtin.debug: |
| 59 | + var: download_result.dest |
| 60 | + verbosity: 1 |
| 61 | + |
| 62 | + - name: Install virtualbox extension pack |
| 63 | + ansible.builtin.shell: "echo 'y' | vboxmanage extpack install --replace {{ download_result.dest }}" |
| 64 | + when: 'extpack_list.stdout == "Extension Packs: 0"' |
| 65 | + |
| 66 | + - name: Download the Oracle Linux iso file |
| 67 | + ansible.builtin.get_url: |
| 68 | + url: 'https://yum.oracle.com/ISOS/OracleLinux/OL{{ ol_version }}/u{{ ol_update }}/x86_64/OracleLinux-R{{ ol_version }}-U{{ ol_update }}-x86_64-dvd.iso' |
| 69 | + dest: /home/{{ username }} |
| 70 | + force: yes |
| 71 | + register: download_iso_result |
| 72 | + until: "'OK' in download_iso_result.msg" |
| 73 | + retries: 5 |
| 74 | + delay: 10 |
0 commit comments