-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstall-tightvnc-and-ssh.yaml
89 lines (79 loc) · 2.76 KB
/
install-tightvnc-and-ssh.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
- name: Setup home server
hosts: all
gather_facts: false
vars:
service_file_location: /etc/systemd/system/[email protected]
tasks:
#https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-18-04
- name: Install tightvnc and ssh
become: true
apt:
update_cache: yes
pkg:
- openssh-server
- tightvncserver
- xfce4
- xfce4-goodies
- name: Backup old config
command: mv /home/{{ ansible_user }}/.vnc/xstartup /home/{{ ansible_user }}/.vnc/xstartup.bak
ignore_errors: True
- name: Setup password
expect:
command: vncpasswd
responses:
Password: "{{ vnc.password }}"
Verify: "{{ vnc.password }}"
"Would you like to enter a view-only password (y/n)?": n
- name: Copy over the new config
copy:
src: tightvnc_config/xstartup
dest: /home/{{ ansible_user }}/.vnc/xstartup
mode: "755"
- name: Copy over the service file for systemd
become: true
copy:
src: tightvnc_config/[email protected]
dest: /etc/systemd/system/[email protected]
- name: "Service file edit: Change User to be {{ ansible_user }}"
become: True
# https://gist.github.com/drmalex07/c0f9304deea566842490
lineinfile:
path: "{{ service_file_location }}"
regexp: '^User=(.*)$'
line: "User={{ ansible_user }}"
backrefs: yes
- name: "Service file edit: Change Group to be {{ ansible_user }}"
become: True
# https://gist.github.com/drmalex07/c0f9304deea566842490
lineinfile:
path: "{{ service_file_location }}"
regexp: '^Group=(.*)$'
line: "Group={{ ansible_user }}"
backrefs: yes
- name: "Service file edit: Change WorkingDirectory to be {{ dir_home }}"
become: True
# https://gist.github.com/drmalex07/c0f9304deea566842490
lineinfile:
path: "{{ service_file_location }}"
regexp: '^WorkingDirectory=(.*)$'
line: "WorkingDirectory={{ dir_home }}"
backrefs: yes
- name: "Service file edit: Change WorkingDirectory to be {{ dir_home }}/.vnc/%H:%i.pid"
become: True
# https://gist.github.com/drmalex07/c0f9304deea566842490
lineinfile:
path: "{{ service_file_location }}"
regexp: '^PIDFile=(.*)$'
line: "PIDFile={{ dir_home }}/.vnc/%H:%i.pid"
backrefs: yes
- name: Reload systemd service
include_tasks: tasks-reload-systemd-service.yaml
vars:
service_name: "vncserver@{{ vnc.display }}.service"
become: True
- include_tasks: tasks-allow-ports.yaml # should already work
vars:
ports:
- "ssh"
- "590{{ vnc.display }}"