-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcloud-init.yml
More file actions
117 lines (111 loc) · 4.3 KB
/
cloud-init.yml
File metadata and controls
117 lines (111 loc) · 4.3 KB
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
#cloud-config
## FAQ ##
# Q: How do I use this file?
# A: Documentation is at: https://www.ntnu.no/wiki/display/iemoodle/%5BLOCAL+VM%5D+Automatic+moodle+setup+with+Multipass+and+cloud-init
# 1. Install multipass (https://multipass.run/).
# 2. Replace the key in "ssh-authorized-keys" section with your own public ssh key
# 3. Add flags to the `sudo bash /home/ubuntu/script` line. Flag documentation is right above
# 3. Open a cmd/powershell/... and run:
# - multipass launch -vvv -n moodle --cloud-init <path to this cloud-init.yml file>
# 4. When the text "Waiting for initialization to complete..." appears,
# just press Ctrl+C to get back to being able to run commands again.
# 5. Run the command:
# - multipass shell moodle
# 6. By now, the vm is still getting set up - it's downloading all the
# packages and moodle files. You can execute the "htop" command
# to get an overview of processes and cpu/memory usage. When you notice
# the cpu usage drops to near 0%, you know it's finished and ready to use.
#
# Q: I see there are other cloud-init files too. What are they for?
# A: This configuration comes WITHOUT SSL/HTTPS. If you either don't own
# a domain name, or you're host this vm on your local machine, you
# won't be able to set up moodle with HTTPS. That means you HAVE
# to use this file when you run "multipass launch ... --cloud-init <file>".
# cloud-init-dns-challenge is for setting up SSL on your moodle
# site using a DNS challenge, while HTTP is for HTTP challenge.
# https://letsencrypt.org/docs/challenge-types/
#
# Q: I'd like to add something to this cloud-init script. What should I watch out for?
# A: 1. Do not leave empty list items "- " anywhere. Example:
# runcmd:
# - echo "$SHELL"
# -
# ^ BAD! Empty list item => The script won't run at all.
#
# 2. When the script starts, the current working directory is /
## TROUBLESHOOTING ##
# Problem: After running multipass launch, it's stuck on
# "Waiting for initialization to complete..."
# Solution: Just ignore this and press Ctrl+C to get back to being able
# to write commands again. See point 4 in "Q: How do I use this file?"
#
# Problem: After running multipass launch, it's stuck on "Starting moodle..."
# Solution: Run these commands:
# - multipass delete moodle
# - multipass purge
# - multipass launch <same parameters as last time>
#
# Problem: Executing multipass commands are generally slow/doesn't work
# Solution: Restart your PC, it's proven to help.
#
# Problem: Script doesn't seem to run at all.
# Solution: See "Q: I'd like to add something [...]"
cloud_config_modules:
- runcmd
cloud_final_modules:
- scripts-user
users:
- name: moodle
groups: sudo
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh-authorized-keys:
# [!] REPLACE WITH YOUR PUBLIC SSH KEY
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHUfvEU4d+Pja79qF9M+k+i230/QhiHih/1d/fn8T76t YourName
# How to generate SSH key on windows 10 and connect to your vm using vs code:
# https://simenwiik.medium.com/passwordless-ssh-between-windows-10-and-ubuntu-server-feat-vs-code-b84f65281376
runcmd:
- sudo apt update
- sudo apt install dos2unix
- wget https://raw.githubusercontent.com/KQMATH/cloud-init-scripts/main/install.sh -O /home/ubuntu/script
- dos2unix /home/ubuntu/script
## RUN SCRIPT ##
# Flags enclosed in [] are optional.
#
# [-v <version>]
# Version of moodle to install. Not case sensitive.
# If omitted, default value "master" is used
# Possible values: master | MOODLE_311_STABLE | MOODLE_39_STABLE
#
# -a <adminpass>
# Moodle web admin password
#
# -d <dbpass>
# Moodle database password
#
# -e <email>
# Email address to associate with the apache web server installation
#
# -i <ip>
# IP address for the server
#
# -g <gateway>
# Gateway IP address
#
# [-m <mask>]
# Subnet mask. Must match gateway settings.
# If omitted, default value 24 is used
#
# [-c]
# Should install CapQuiz
#
# [-q]
# Should install QTracker
#
# [-s]
# Should install Stack
#
# [-t]
# Should install ShortMath
#
- sudo bash /home/ubuntu/script [-v MOODLEVERSION] [-cqst] -e EMAIL -a ADMINPASS -d DBPASS -i IPADDRESS -g GATEWAYIP