Skip to content

Commit cb16eb6

Browse files
committed
add vnc to devops node for django csrf
1 parent 9de9bc5 commit cb16eb6

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

olam/create_instance.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@
343343
ansible.builtin.import_playbook: provision_kvm.yml
344344
when: use_kvm
345345

346+
- name: Provision vnc server on devops node
347+
ansible.builtin.import_playbook: provision_vnc.yml
348+
when: use_devops_vnc
349+
346350
- name: Provision Oracle Linux Automation Builder Utility
347351
ansible.builtin.import_playbook: provision_builder.yml
348352
when: use_olam_builder

olam/default_vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ update_all: false
2323
passwordless_ssh: false
2424
olam_type: single
2525
# use_olae_only: false
26+
use_devops_vnc: false
2627
use_olam_builder: false
2728
use_olam_pah: false
2829
add_pah_ports: false

olam/provision_vnc.yml

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

0 commit comments

Comments
 (0)