-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloud-init-dns-challenge.yml
90 lines (82 loc) · 4.16 KB
/
cloud-init-dns-challenge.yml
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
#cloud-config
## FAQ ##
# Q: How do I use this file?
# A: 1. Install multipass (https://multipass.run/).
# 2. Replace the key in "ssh-authorized-keys" section with your own public ssh key
# 3. Uncomment the moodle plugins in section 3 you want to install
# 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 this time, 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/
## 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.
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:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHUfvEU4d+Pj793B9MZk+iqP0/nV6FJgN/fv/Ax1gDb1 SimenMoodle
# ^ REPLACE WITH YOUR PUBLIC SSH KEY
# 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:
## 1 | INSTALL DEPENDENCIES ##
- "sudo add-apt-repository ppa:ondrej/php"
- "sudo add-apt-repository ppa:ondrej/apache2"
- sudo apt update
- sudo apt install -y apache2 php8.0 php-pear phppgadmin php-curl php-zip php-gd php-intl php-soap php-xmlrpc php-mbstring maxima postgresql
## CHOOSE ONE START ##
# https://certbot.eff.org/lets-encrypt/ubuntufocal-apache
# 1. dns challenge (supports wildcard certificates)
# see https://certbot.eff.org/glossary#wildcard-certificate
# - sudo snap install --classic certbot
# - sudo ln -s /snap/bin/certbot /usr/bin/certbot
# - sudo snap set certbot trust-plugin-with-root=ok
## CHOOSE ONE END ##
## 2 | CONFIGURE DATABASE ##
- sudo -u postgres psql -c "CREATE USER moodleuser WITH PASSWORD 'KlasseromsQuiz'";
- sudo -u postgres psql -c "CREATE DATABASE moodle WITH OWNER moodleuser";
- sudo sh -c 'echo "host all all 0.0.0.0/0 trust" >> /etc/postgresql/12/main/pg_hba.conf'
## 3 | DOWNLOAD MOODLE AND OPTIONAL MODS/QTYPES/... ##
- git clone --recursive https://github.com/moodle/moodle.git /var/www/moodle
# OPTIONAL: Uncomment to install ShortMath
# - git clone https://github.com/KQMATH/moodle-qtype_shortmath.git /var/www/moodle/question/type/shortmath
# OPTIONAL: Uncomment to install CapQuiz
# - git clone https://github.com/KQMATH/moodle-mod_capquiz.git /var/www/moodle/
# OPTIONAL: Uncomment to install Stack
- git clone https://github.com/KQMATH/moodle-qtype_stack.git /var/www/moodle/question/type/stack
- sudo chown -R moodle /var/www/
## 4 | UPDATE CONFIGURATION FILES ##
-