Skip to content

Commit 64fd8c7

Browse files
authored
Merge pull request #25 from bgraef/main
add use_vnc code
2 parents 5068657 + b74acf4 commit 64fd8c7

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

ol/create_instance.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@
307307
ansible.builtin.import_playbook: provision_podman.yml
308308
when: use_podman
309309

310+
- name: Provision VNC Server
311+
ansible.builtin.import_playbook: provision_vnc.yml
312+
when: use_vnc
313+
310314
- name: Print instances
311315
hosts: all
312316
become: true

ol/default_vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ debug_enabled: false
1616
#ceph_volume_size_in_gbs: 50
1717
#add_ceph_deployments: false
1818

19+
use_vnc: false
1920
vnc_port: "1"
2021
vnc_default_password: "oracle"
2122
vnc_geometry: "1920x1080"

ol/provision_vnc.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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 Podman and Container Tools
8+
hosts: server
9+
vars_files:
10+
- default_vars.yml
11+
become: true
12+
13+
tasks:
14+
15+
- name: Install the "Server with GUI" package group
16+
ansible.builtin.dnf:
17+
name: '@Server with GUI'
18+
state: present
19+
20+
- name: Installing the vnc package
21+
ansible.builtin.dnf:
22+
name:
23+
- tigervnc-server
24+
- tigervnc-server-module
25+
state: present
26+
27+
- name: Set systemd default boot target to graphical.target
28+
ansible.builtin.file:
29+
src: /usr/lib/systemd/system/graphical.target
30+
dest: /etc/systemd/system/default.target
31+
state: link
32+
33+
- name: Set vncserver systemd template
34+
ansible.builtin.file:
35+
src: /usr/lib/systemd/system/[email protected]
36+
dest: /etc/systemd/system/[email protected]
37+
state: link
38+
39+
- name: Assign username to vnc port
40+
ansible.builtin.lineinfile:
41+
path: /etc/tigervnc/vncserver.users
42+
line: ":{{ vnc_port }}={{ username }}"
43+
44+
- name: Set vnc geometry and session
45+
ansible.builtin.blockinfile:
46+
path: /etc/tigervnc/vncserver-config-defaults
47+
block: |
48+
session=gnome
49+
geometry={{ vnc_geometry }}
50+
51+
- name: Create .vnc directory for user
52+
ansible.builtin.file:
53+
path: /home/{{ username }}/.vnc
54+
state: directory
55+
mode: '0700'
56+
owner: "{{ username }}"
57+
group: "{{ username }}"
58+
59+
- name: Generate vnc password for the remote user
60+
ansible.builtin.shell: |
61+
set -o pipefail
62+
echo {{ vnc_default_password }} | vncpasswd -f > /home/{{ username }}/.vnc/passwd
63+
args:
64+
chdir: "/home/{{ username }}/.vnc"
65+
creates: "/home/{{ username }}/.vnc/passwd"
66+
executable: /bin/bash
67+
68+
- name: Change the permission to 600 for .vnc/passwd file
69+
ansible.builtin.file:
70+
path: "/home/{{ username }}/.vnc/passwd"
71+
owner: "{{ username }}"
72+
group: "{{ usergroup }}"
73+
mode: '0600'
74+
75+
- name: Start and enable the vnc service
76+
ansible.builtin.systemd:
77+
state: started
78+
daemon_reload: true
79+
name: vncserver@:{{ vnc_port }}.service
80+
enabled: true

0 commit comments

Comments
 (0)