Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add use_vnc code #25

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ol/create_instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@
ansible.builtin.import_playbook: provision_podman.yml
when: use_podman

- name: Provision VNC Server
ansible.builtin.import_playbook: provision_vnc.yml
when: use_vnc

- name: Print instances
hosts: all
become: true
Expand Down
1 change: 1 addition & 0 deletions ol/default_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ debug_enabled: false
#ceph_volume_size_in_gbs: 50
#add_ceph_deployments: false

use_vnc: false
vnc_port: "1"
vnc_default_password: "oracle"
vnc_geometry: "1920x1080"
Expand Down
80 changes: 80 additions & 0 deletions ol/provision_vnc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
# 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 Podman and Container Tools
hosts: server
vars_files:
- default_vars.yml
become: true

tasks:

- name: Install the "Server with GUI" package group
ansible.builtin.dnf:
name: '@Server with GUI'
state: present

- name: Installing the vnc package
ansible.builtin.dnf:
name:
- tigervnc-server
- tigervnc-server-module
state: present

- name: Set systemd default boot target to graphical.target
ansible.builtin.file:
src: /usr/lib/systemd/system/graphical.target
dest: /etc/systemd/system/default.target
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

- name: Assign username to vnc port
ansible.builtin.lineinfile:
path: /etc/tigervnc/vncserver.users
line: ":{{ vnc_port }}={{ username }}"

- name: Set vnc geometry and session
ansible.builtin.blockinfile:
path: /etc/tigervnc/vncserver-config-defaults
block: |
session=gnome
geometry={{ vnc_geometry }}

- name: Create .vnc directory for user
ansible.builtin.file:
path: /home/{{ username }}/.vnc
state: directory
mode: '0700'
owner: "{{ username }}"
group: "{{ username }}"

- name: Generate vnc password for the remote user
ansible.builtin.shell: |
set -o pipefail
echo {{ vnc_default_password }} | vncpasswd -f > /home/{{ username }}/.vnc/passwd
args:
chdir: "/home/{{ username }}/.vnc"
creates: "/home/{{ username }}/.vnc/passwd"
executable: /bin/bash

- name: Change the permission to 600 for .vnc/passwd file
ansible.builtin.file:
path: "/home/{{ username }}/.vnc/passwd"
owner: "{{ username }}"
group: "{{ usergroup }}"
mode: '0600'

- name: Start and enable the vnc service
ansible.builtin.systemd:
state: started
daemon_reload: true
name: vncserver@:{{ vnc_port }}.service
enabled: true