Skip to content

Commit

Permalink
add use_vnc code
Browse files Browse the repository at this point in the history
  • Loading branch information
bgraef committed Jul 18, 2024
1 parent 5068657 commit b74acf4
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
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/vncserver@.service
dest: /etc/systemd/system/vncserver@.service
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

0 comments on commit b74acf4

Please sign in to comment.