-
Notifications
You must be signed in to change notification settings - Fork 0
/
user-data.yaml
218 lines (218 loc) · 6.43 KB
/
user-data.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#cloud-config
# - Required Extra Vars
# $INTERFACE
# $STATIC_IP_ADDRESS
# $GATEWAY_IP
# $DNS_SERVER_IP
# $EDITOR_VERSION
hostname: ${VM_NAME}
fqdn: ${VM_NAME}
disable_root: false
network:
config: disabled
users:
- name: ${USERNAME}
groups: users, admin, docker, sudo
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
lock_passwd: false
passwd: ${PASSWORD}
ssh_import_id:
- gh:${GITHUB_USER}
- name: ${VM_ADMIN}
gecos: system acct
groups: users, admin, docker, sudo
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
lock_passwd: false
passwd: ${PASSWORD}
ssh_authorized_keys:
- ${VM_KEY}
write_files:
- path: /etc/netplan/99-my-new-config.yaml
permissions: '0644'
content: |
network:
ethernets:
${INTERFACE}:
dhcp4: no
dhcp6: no
addresses: [${STATIC_IP_ADDRESS}/24]
routes:
- to: default
via: ${GATEWAY_IP}
mtu: 1500
nameservers:
addresses: [${DNS_SERVER_IP}]
renderer: networkd
version: 2
- path: /etc/unity-hub
permissions: '0644'
content: |
#!/bin/bash
xvfb-run -ae /dev/stdout /opt/unityhub/unityhub-bin --no-sandbox --headless "\$@"
- path: /etc/gdm3/daemon.conf
content: |
# GDM configuration storage
#
# /etc/gdm3/custom.conf on ubuntu
# /etc/gdm3/daemon.conf on debian
[daemon]
# Uncoment the line below to force the login screen to use Xorg
WaylandEnable=false
# Enabling automatic login
AutomaticLoginEnable = true
AutomaticLogin = ${USERNAME}
# Enabling timed login
# TimedLoginEnable = true
# TimedLogin = user1
# TimedLoginDelay = 10
[security]
[xdmcp]
[chooser]
[debug]
# Uncomment the line below to turn on debugging
# More verbose logs
# Additionally lets the X server dump core if it crashes
#Enable=true
- path: /etc/systemd/sleep.conf.d/nosuspend.conf
content: |
[Sleep]
AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no
- path: /etc/X11/xorg.conf
content: |
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
ModulePath "/usr/lib/xorg/modules"
FontPath "built-ins"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5 6 7"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
EndSection
Section "Monitor"
Identifier "Monitor1"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
EndSection
Section "Device"
Identifier "Card0"
Driver "nvidia"
BusID "PCI:0:2:0"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "3840x2160" "2560x1440" "1920x1080" "1600x900" "1366x768" "1280x1024" "1024x768" "640x480"
EndSubSection
EndSection
snap:
commands:
00: ['install', '--beta', 'steam']
01: ['install', 'firefox']
# We have to use the snap version of firefox because the apt-version is not correctly
# detected as the system default which causes errors when unity-hub tries to authenticate
apt:
primary:
- arches: [default]
uri: http://us.archive.ubuntu.com/ubuntu/
sources:
unityhub.list:
source: deb https://hub.unity3d.com/linux/repos/deb stable main
package_update: true
package_upgrade: true
packages:
- apt-utils
- ca-certificates
- libasound2
- libc6-dev
- libcap2
- libgconf-2-4
- libglu1
- libgtk-3-0
- libncurses5
- libnotify4
- libnss3
- libxtst6
- libxss1
- cpio
- lsb-release
- python3-pip
- docker.io
- python-setuptools
- xz-utils
- atop
- curl
- git
- git-lfs
- jq
- openssh-client
- wget
- software-properties-common
- zenity
- libgbm1
- gnupg
- x11vnc
- ubuntu-desktop
- xvfb
- xterm
- net-tools
- ubuntu-drivers-common
- linux-headers-generic
# workaround for https://askubuntu.com/questions/1436601/ubuntu-drivers-unboundlocalerror-local-variable-version-referenced-before-as
bootcmd:
- mkdir -p "/opt/unityhub/chrome-sandbox"
- mkdir -p "/opt/unity/editors"
runcmd:
#---Updating network config for use with static ip addressing---
- netplan --degug generate
- netplan --debug apply
- rm /etc/netplan/50*
#---Downloading xorg.conf---"
- curl https://raw.githubusercontent.com/cloudymax/Scrap-Metal/main/virtual-machines/qemu/configs/xorg.conf.headless > /tmp/xorg.conf
- cp /tmp/xorg.conf /etc/X11/xorg.conf
#---installing older version of SSL as workaround for Unity Hub failing to launch---
- wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
- sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
- rm libssl1.1_1.1.1f-1ubuntu2_amd64.deb
#---Downloading Unity's Apt Key manually since its not in the Ubuntu keyserver---
- wget -qO- https://hub.unity3d.com/linux/keys/public | apt-key add -
#---Installing UnityHub---
- apt-get update -y
- apt-get install -y unityhub
- mv /etc/unity-hub /usr/bin/unity-hub
#--- Doanload and install Unity Editor version 2022.1.23f1---
- sudo xvfb-run -ae /dev/stdout /opt/unityhub/unityhub-bin --no-sandbox --headless install-path --set "/opt/unity/editors"
- sudo xvfb-run -ae /dev/stdout /opt/unityhub/unityhub-bin --no-sandbox --headless install -v 2022.1.23f1
#---installing git lfs---
- git lfs install --system --skip-repo
#---Setting SSH port and options---
- sed -i -e '/^Port/s/^.*$/Port 22/' /etc/ssh/sshd_config
- sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
- sed -i -e '/^PasswordAuthentication/s/^.*$/PasswordAuthentication yes/' /etc/ssh/sshd_config
- systemctl restart sshd
- ubuntu-drivers install nvidia:525