From fe36ea403f258699b48a2592300aac256fb4fa4b Mon Sep 17 00:00:00 2001 From: William Graef Date: Sat, 28 Sep 2024 15:23:16 -0400 Subject: [PATCH 1/6] add vbox install --- ol/create_instance.yml | 4 +++ ol/default_vars.yml | 7 ++++ ol/provision_vbox.yml | 74 ++++++++++++++++++++++++++++++++++++++++++ ol/provision_vnc.yml | 4 +-- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 ol/provision_vbox.yml 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..56a0021 --- /dev/null +++ b/ol/provision_vbox.yml @@ -0,0 +1,74 @@ +--- +# 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 required packages for virtualbox + ansible.builtin.dnf: + name: + - "kernel-uek-devel-{{ ansible_kernel }}" + - gcc + - make + - perl + state: latest + + - 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: latest + + - name: Check if extension pack is already installed + ansible.builtin.shell: "vboxmanage list extpacks" + register: extpack_list + + - name: Output installed extpacks + ansible.builtin.debug: + var: extpack_list.stdout + verbosity: 1 + + - name: Download virtualbox extension pack + ansible.builtin.get_url: + url: 'https://download.virtualbox.org/virtualbox/{{ virtualbox_extpack_version }}/Oracle_VirtualBox_Extension_Pack-{{ virtualbox_extpack_version }}.vbox-extpack' + dest: /tmp/ + force: yes + register: download_result + when: 'extpack_list.stdout == "Extension Packs: 0"' + + - 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: "echo 'y' | vboxmanage extpack install --replace {{ download_result.dest }}" + when: 'extpack_list.stdout == "Extension Packs: 0"' + + - name: Download the Oracle Linux iso file + ansible.builtin.get_url: + 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' + dest: /home/{{ username }} + force: yes + register: download_iso_result + until: "'OK' in download_iso_result.msg" + retries: 5 + delay: 10 diff --git a/ol/provision_vnc.yml b/ol/provision_vnc.yml index 3f7d972..e6ccc39 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 From 339158829a473f3750fbdc2466e67eab40accb0b Mon Sep 17 00:00:00 2001 From: William Graef Date: Sat, 28 Sep 2024 16:06:00 -0400 Subject: [PATCH 2/6] lint fixes and add libxcb pkg --- ol/provision_vbox.yml | 117 +++++++++++++++++++++++------------------ ol/update_all_rpms.yml | 2 +- 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/ol/provision_vbox.yml b/ol/provision_vbox.yml index 56a0021..674e774 100644 --- a/ol/provision_vbox.yml +++ b/ol/provision_vbox.yml @@ -12,63 +12,78 @@ tasks: - - name: Install required packages for virtualbox - ansible.builtin.dnf: - name: - - "kernel-uek-devel-{{ ansible_kernel }}" - - gcc - - make - - perl - state: latest + - name: Install required packages for virtualbox + ansible.builtin.dnf: + name: + - "kernel-uek-devel-{{ ansible_kernel }}" + - gcc + - make + - perl + - libxcb + 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 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: 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: latest + - 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 + - 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: Output installed extpacks + ansible.builtin.debug: + var: extpack_list.stdout + verbosity: 1 - - name: Download virtualbox extension pack - ansible.builtin.get_url: - url: 'https://download.virtualbox.org/virtualbox/{{ virtualbox_extpack_version }}/Oracle_VirtualBox_Extension_Pack-{{ virtualbox_extpack_version }}.vbox-extpack' - dest: /tmp/ - force: yes - register: download_result - when: 'extpack_list.stdout == "Extension Packs: 0"' + - 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: Output download virtualbox extension pack file name + ansible.builtin.debug: + var: download_result.dest + verbosity: 1 - - name: Install virtualbox extension pack - ansible.builtin.shell: "echo 'y' | vboxmanage extpack install --replace {{ download_result.dest }}" - when: 'extpack_list.stdout == "Extension Packs: 0"' + - 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: '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' - dest: /home/{{ username }} - force: yes - register: download_iso_result - until: "'OK' in download_iso_result.msg" - retries: 5 - delay: 10 + - name: Download the Oracle Linux iso file + ansible.builtin.get_url: + url: "{{ base_url }}/OL{{ ol_version }}/u{{ ol_update }}/x86_64/OracleLinux-R{{ ol_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/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 From 91e01cf3cbb4faec7c3fc2c2046cec48a4dad889 Mon Sep 17 00:00:00 2001 From: William Graef Date: Sat, 28 Sep 2024 16:18:10 -0400 Subject: [PATCH 3/6] fix xcb dependency --- ol/provision_vbox.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ol/provision_vbox.yml b/ol/provision_vbox.yml index 674e774..f4b6298 100644 --- a/ol/provision_vbox.yml +++ b/ol/provision_vbox.yml @@ -19,7 +19,7 @@ - gcc - make - perl - - libxcb + - xcb-util-cursor state: present - name: Add virtualbox repo keys From ded65f46059c92234b27a28adbfb627bf0d349de Mon Sep 17 00:00:00 2001 From: William Graef Date: Sat, 28 Sep 2024 17:04:37 -0400 Subject: [PATCH 4/6] update vnc syntax and vbox pkg dep --- ol/provision_vbox.yml | 13 +++++++++++++ ol/provision_vnc.yml | 18 +++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ol/provision_vbox.yml b/ol/provision_vbox.yml index f4b6298..3823258 100644 --- a/ol/provision_vbox.yml +++ b/ol/provision_vbox.yml @@ -12,6 +12,19 @@ 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: diff --git a/ol/provision_vnc.yml b/ol/provision_vnc.yml index e6ccc39..9b065b0 100644 --- a/ol/provision_vnc.yml +++ b/ol/provision_vnc.yml @@ -30,11 +30,11 @@ dest: /etc/systemd/system/default.target 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 + # - name: Set vncserver systemd template + # ansible.builtin.file: + # src: /usr/lib/systemd/system/vncserver@.service + # dest: /etc/systemd/system/vncserver@.service + # state: link - name: Assign username to vnc port ansible.builtin.lineinfile: @@ -52,7 +52,7 @@ ansible.builtin.file: path: /home/{{ username }}/.vnc state: directory - mode: '0700' + mode: "0700" owner: "{{ username }}" group: "{{ username }}" @@ -70,11 +70,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 From 69de93d08281d1bc9a9a98f101529eb7c194f0c1 Mon Sep 17 00:00:00 2001 From: William Graef Date: Sat, 28 Sep 2024 17:51:50 -0400 Subject: [PATCH 5/6] cp vnc systemd to etc --- ol/provision_vnc.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ol/provision_vnc.yml b/ol/provision_vnc.yml index 9b065b0..85a7a18 100644 --- a/ol/provision_vnc.yml +++ b/ol/provision_vnc.yml @@ -30,11 +30,12 @@ dest: /etc/systemd/system/default.target 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 + - name: Set vncserver systemd template + 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: From d046123af85aeef7eee4ab96abe9be700820f8d4 Mon Sep 17 00:00:00 2001 From: William Graef Date: Sat, 28 Sep 2024 18:05:10 -0400 Subject: [PATCH 6/6] fix ol iso version var --- ol/provision_vbox.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ol/provision_vbox.yml b/ol/provision_vbox.yml index 3823258..7155a2c 100644 --- a/ol/provision_vbox.yml +++ b/ol/provision_vbox.yml @@ -90,7 +90,7 @@ - name: Download the Oracle Linux iso file ansible.builtin.get_url: - url: "{{ base_url }}/OL{{ ol_version }}/u{{ ol_update }}/x86_64/OracleLinux-R{{ ol_version }}-U{{ ol_update }}-x86_64-dvd.iso" + 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"