NextCloud-prep/README.md

110 lines
2.9 KiB
Markdown
Raw Normal View History

This is a Ansible playbook for configuring a stock Debian 12 (bookworm)
cloud image to install NextCloud under a LAMP stack.
NOTE! The stanzas reponsible for creating the /data filesystem on vdb in
roles/system/tasks/main.yml have been commented out for testing, remember
to uncomment them before you run this in production.
This was tested on a Debian-derived x86_64 system with 8GB RAM and 4 cores
under QEMU/KVM.
To test this playbook on a Debian-based OS using QEMU/KVM, do the following:
- Install the following packages if not already installed:
* ansible
* ansible-lint
* cloud-init
* cloud-guest-utils
* cloud-image-utils
* qemu-system-x86_64
* qemu-utils
* ssh
* ssh-askpass
* wget
* whois (for mkpasswd)
- Copy the file cloud-init.cfg from the data/ directory
NOTE! this is a YAML file, proper spacing is required!
The hashed password was created using
```
$ mkpasswd -m sha-512
```
- Create the seed image:
```
cloud-localds seed.iso cloud-init.cfg
```
- Download the latest debian 12 cloud image if you haven't done so already:
```
wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
```
NOTE! Do *NOT* try to use the generic cloud image, it will *NOT* work!
- Copy the cloud image because cloud-init will change the image the first
time you run it under QEMU:
```
cp debian-12-generic-amd64.qcow2 test.qcow2
```
- The cloud image is only something like 2GB and installing anything
substantial on it will fail, so you need to resize it:
```
qemu-img resize test.qcow2 10G
```
- Start the VM:
```
qemu-system-x86_64 \
-name test \
-machine pc-q35-5.2,accel=kvm \
-cpu host \
-m 4096 \
-nographic \
-boot strict=on \
-drive file=test.qcow2,format=qcow2,media=disk \
-drive file=seed.iso,media=cdrom \
-nic user,ipv6=off,model=e1000,hostfwd=tcp:127.0.0.1:6666-:22,hostfwd=tcp:${SSH_HOST}:8080-:80
```
- After the VM has started and cloud-init has finished and you see a login
prompt, do the following in another terminal to run the ansible playbook:
```
export ANSIBLE_HOST_KEY_CHECKING=False
ansible-playbook site.yml --user installer --ask-pass -i hosts
```
when it asks you for the SSH password, type "password"
- If the installation is successful, it will print the MariaDB root and
nextcloud user's passwords. Be sure to copy these down, you will need
them when you configure NextCloud from your browser. The NextCloud
database is "nextcloud" and the user is "nextcloud".
- Once the VM is running, you can ssh to it using the following:
```
ssh-keygen -f "${HOME}/.ssh/known_hosts" -R "[127.0.0.1]:6666"
ssh installer@127.0.0.1 -p 6666
```
the password is "password"
After Ansible finishes installing NextCloud, you will be able to reach the
webserver running on the VM by going to localhost:8080 in your browser.
Follow the onscreen directions to finish configuring NextCloud using the
database passwords Ansible provides at the end of the installation.