From 45742ccac7162c9300d50926923754969832f4ec Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Sun, 12 Sep 2021 13:14:40 -0400 Subject: [PATCH] prep switch to ansible --- README.md | 28 +++++- post-install/ansible.cfg => ansible.cfg | 0 post-install/hosts => hosts | 0 kvm-vm.yml | 0 post-install/playbook.yml => playbook.yml | 0 qemu-vm.yml | 0 .../roles => roles}/rsync/tasks/main.yml | 0 .../rsync/templates/rsyncd-filter.conf.j2 | 0 .../rsync/templates/rsyncd.conf.j2 | 0 .../roles => roles}/setup/tasks/main.yml | 0 .../roles => roles}/zfs/tasks/main.yml | 0 tasks/a | 0 {post-install => todo}/README.md | 0 {post-install => todo}/ftp/README.md | 0 .../ftp/include/favicon.ico | Bin {post-install => todo}/ftp/include/header.png | Bin {post-install => todo}/ftp/include/motd.msg | 0 {post-install => todo}/ftp/proftpd.conf | 0 {post-install => todo}/index/README.md | 0 {post-install => todo}/index/csc-mirror | 0 .../index/mirror-index/config.yaml | 0 .../index/mirror-index/index.css | 0 .../index/mirror-index/index.mako | 0 .../index/mirror-index/make-index.py | 0 {post-install => todo}/nginx/README.md | 0 .../nginx/includes/ceph.conf | 0 .../nginx/includes/csc-debian.conf | 0 .../nginx/includes/mirror.conf | 0 .../nginx/includes/ssl.conf | 0 .../nginx/includes/ubuntu.conf | 0 {post-install => todo}/nginx/mime.types | 0 {post-install => todo}/nginx/nginx.conf | 0 .../nginx/sites-available/debian.conf | 0 .../nginx/sites-available/default | 0 .../nginx/sites-available/default.dpkg-dist | 0 .../nginx/sites-available/mirror.conf | 0 todo/vm-install-op2/main.yml | 67 ++++++++++++ todo/vm-install-op2/mirror.txt | 95 ++++++++++++++++++ todo/vm-install-op2/mirrornetwork.xml | 14 +++ todo/vm-install-op2/thing | 30 ++++++ 40 files changed, 229 insertions(+), 5 deletions(-) rename post-install/ansible.cfg => ansible.cfg (100%) rename post-install/hosts => hosts (100%) create mode 100644 kvm-vm.yml rename post-install/playbook.yml => playbook.yml (100%) mode change 100755 => 100644 create mode 100644 qemu-vm.yml rename {post-install/roles => roles}/rsync/tasks/main.yml (100%) rename {post-install/roles => roles}/rsync/templates/rsyncd-filter.conf.j2 (100%) rename {post-install/roles => roles}/rsync/templates/rsyncd.conf.j2 (100%) rename {post-install/roles => roles}/setup/tasks/main.yml (100%) rename {post-install/roles => roles}/zfs/tasks/main.yml (100%) create mode 100644 tasks/a rename {post-install => todo}/README.md (100%) rename {post-install => todo}/ftp/README.md (100%) rename {post-install => todo}/ftp/include/favicon.ico (100%) rename {post-install => todo}/ftp/include/header.png (100%) rename {post-install => todo}/ftp/include/motd.msg (100%) rename {post-install => todo}/ftp/proftpd.conf (100%) rename {post-install => todo}/index/README.md (100%) rename {post-install => todo}/index/csc-mirror (100%) rename {post-install => todo}/index/mirror-index/config.yaml (100%) rename {post-install => todo}/index/mirror-index/index.css (100%) rename {post-install => todo}/index/mirror-index/index.mako (100%) rename {post-install => todo}/index/mirror-index/make-index.py (100%) rename {post-install => todo}/nginx/README.md (100%) rename {post-install => todo}/nginx/includes/ceph.conf (100%) rename {post-install => todo}/nginx/includes/csc-debian.conf (100%) rename {post-install => todo}/nginx/includes/mirror.conf (100%) rename {post-install => todo}/nginx/includes/ssl.conf (100%) rename {post-install => todo}/nginx/includes/ubuntu.conf (100%) rename {post-install => todo}/nginx/mime.types (100%) rename {post-install => todo}/nginx/nginx.conf (100%) rename {post-install => todo}/nginx/sites-available/debian.conf (100%) rename {post-install => todo}/nginx/sites-available/default (100%) rename {post-install => todo}/nginx/sites-available/default.dpkg-dist (100%) rename {post-install => todo}/nginx/sites-available/mirror.conf (100%) create mode 100644 todo/vm-install-op2/main.yml create mode 100644 todo/vm-install-op2/mirror.txt create mode 100644 todo/vm-install-op2/mirrornetwork.xml create mode 100644 todo/vm-install-op2/thing diff --git a/README.md b/README.md index 5dc1c90..6d7f4c7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Mirror Env This script helps quickly set up a vm development environment for cs club's mirrors. -## Installation +## VM Installation Option 1 (qmeu-vm.yml) Install the following dependencies - qemu - genisoimage @@ -36,6 +36,27 @@ The default login user has username: ubuntu password: ubuntu ``` +### Run Playbook +``` +ansible-playbook qemu-vm.yml +``` + +## VM Install Option 2 (kvm) + +### Install Packages (debian) +``` +$ apt install qemu-kvm libvirt virt-install virt-viewer ansible +``` + +### Install Packages (archlinux) +``` +$ pacman -S qemu libvirt virt-install virt-viewer ansible +``` + +### Run Playbook +``` +ansible-playbook kvm-vm.yml +``` ## Post-Installation The ubunutu autoinstall can only handle basic installation. We require a more powerful tool to configure the post-install environment. For this reason, we will be using ansible. @@ -53,10 +74,8 @@ $ ansible-playbook -K playbook.yml ``` ## System Details -For those that are interested. - -relevant lsblk output: ``` +$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 10G 0 disk ├─vda1 252:1 0 500M 0 part /boot/efi @@ -81,5 +100,4 @@ vdf 252:80 0 10G 0 disk ├─vdf1 252:81 0 10G 0 part └─vdf9 252:89 0 8M 0 part ``` - Drives vda and vdb are for the main filesystem, they use raid1. Drives vdc, vdd, vde and vdf are in a raidz2 zpool. diff --git a/post-install/ansible.cfg b/ansible.cfg similarity index 100% rename from post-install/ansible.cfg rename to ansible.cfg diff --git a/post-install/hosts b/hosts similarity index 100% rename from post-install/hosts rename to hosts diff --git a/kvm-vm.yml b/kvm-vm.yml new file mode 100644 index 0000000..e69de29 diff --git a/post-install/playbook.yml b/playbook.yml old mode 100755 new mode 100644 similarity index 100% rename from post-install/playbook.yml rename to playbook.yml diff --git a/qemu-vm.yml b/qemu-vm.yml new file mode 100644 index 0000000..e69de29 diff --git a/post-install/roles/rsync/tasks/main.yml b/roles/rsync/tasks/main.yml similarity index 100% rename from post-install/roles/rsync/tasks/main.yml rename to roles/rsync/tasks/main.yml diff --git a/post-install/roles/rsync/templates/rsyncd-filter.conf.j2 b/roles/rsync/templates/rsyncd-filter.conf.j2 similarity index 100% rename from post-install/roles/rsync/templates/rsyncd-filter.conf.j2 rename to roles/rsync/templates/rsyncd-filter.conf.j2 diff --git a/post-install/roles/rsync/templates/rsyncd.conf.j2 b/roles/rsync/templates/rsyncd.conf.j2 similarity index 100% rename from post-install/roles/rsync/templates/rsyncd.conf.j2 rename to roles/rsync/templates/rsyncd.conf.j2 diff --git a/post-install/roles/setup/tasks/main.yml b/roles/setup/tasks/main.yml similarity index 100% rename from post-install/roles/setup/tasks/main.yml rename to roles/setup/tasks/main.yml diff --git a/post-install/roles/zfs/tasks/main.yml b/roles/zfs/tasks/main.yml similarity index 100% rename from post-install/roles/zfs/tasks/main.yml rename to roles/zfs/tasks/main.yml diff --git a/tasks/a b/tasks/a new file mode 100644 index 0000000..e69de29 diff --git a/post-install/README.md b/todo/README.md similarity index 100% rename from post-install/README.md rename to todo/README.md diff --git a/post-install/ftp/README.md b/todo/ftp/README.md similarity index 100% rename from post-install/ftp/README.md rename to todo/ftp/README.md diff --git a/post-install/ftp/include/favicon.ico b/todo/ftp/include/favicon.ico similarity index 100% rename from post-install/ftp/include/favicon.ico rename to todo/ftp/include/favicon.ico diff --git a/post-install/ftp/include/header.png b/todo/ftp/include/header.png similarity index 100% rename from post-install/ftp/include/header.png rename to todo/ftp/include/header.png diff --git a/post-install/ftp/include/motd.msg b/todo/ftp/include/motd.msg similarity index 100% rename from post-install/ftp/include/motd.msg rename to todo/ftp/include/motd.msg diff --git a/post-install/ftp/proftpd.conf b/todo/ftp/proftpd.conf similarity index 100% rename from post-install/ftp/proftpd.conf rename to todo/ftp/proftpd.conf diff --git a/post-install/index/README.md b/todo/index/README.md similarity index 100% rename from post-install/index/README.md rename to todo/index/README.md diff --git a/post-install/index/csc-mirror b/todo/index/csc-mirror similarity index 100% rename from post-install/index/csc-mirror rename to todo/index/csc-mirror diff --git a/post-install/index/mirror-index/config.yaml b/todo/index/mirror-index/config.yaml similarity index 100% rename from post-install/index/mirror-index/config.yaml rename to todo/index/mirror-index/config.yaml diff --git a/post-install/index/mirror-index/index.css b/todo/index/mirror-index/index.css similarity index 100% rename from post-install/index/mirror-index/index.css rename to todo/index/mirror-index/index.css diff --git a/post-install/index/mirror-index/index.mako b/todo/index/mirror-index/index.mako similarity index 100% rename from post-install/index/mirror-index/index.mako rename to todo/index/mirror-index/index.mako diff --git a/post-install/index/mirror-index/make-index.py b/todo/index/mirror-index/make-index.py similarity index 100% rename from post-install/index/mirror-index/make-index.py rename to todo/index/mirror-index/make-index.py diff --git a/post-install/nginx/README.md b/todo/nginx/README.md similarity index 100% rename from post-install/nginx/README.md rename to todo/nginx/README.md diff --git a/post-install/nginx/includes/ceph.conf b/todo/nginx/includes/ceph.conf similarity index 100% rename from post-install/nginx/includes/ceph.conf rename to todo/nginx/includes/ceph.conf diff --git a/post-install/nginx/includes/csc-debian.conf b/todo/nginx/includes/csc-debian.conf similarity index 100% rename from post-install/nginx/includes/csc-debian.conf rename to todo/nginx/includes/csc-debian.conf diff --git a/post-install/nginx/includes/mirror.conf b/todo/nginx/includes/mirror.conf similarity index 100% rename from post-install/nginx/includes/mirror.conf rename to todo/nginx/includes/mirror.conf diff --git a/post-install/nginx/includes/ssl.conf b/todo/nginx/includes/ssl.conf similarity index 100% rename from post-install/nginx/includes/ssl.conf rename to todo/nginx/includes/ssl.conf diff --git a/post-install/nginx/includes/ubuntu.conf b/todo/nginx/includes/ubuntu.conf similarity index 100% rename from post-install/nginx/includes/ubuntu.conf rename to todo/nginx/includes/ubuntu.conf diff --git a/post-install/nginx/mime.types b/todo/nginx/mime.types similarity index 100% rename from post-install/nginx/mime.types rename to todo/nginx/mime.types diff --git a/post-install/nginx/nginx.conf b/todo/nginx/nginx.conf similarity index 100% rename from post-install/nginx/nginx.conf rename to todo/nginx/nginx.conf diff --git a/post-install/nginx/sites-available/debian.conf b/todo/nginx/sites-available/debian.conf similarity index 100% rename from post-install/nginx/sites-available/debian.conf rename to todo/nginx/sites-available/debian.conf diff --git a/post-install/nginx/sites-available/default b/todo/nginx/sites-available/default similarity index 100% rename from post-install/nginx/sites-available/default rename to todo/nginx/sites-available/default diff --git a/post-install/nginx/sites-available/default.dpkg-dist b/todo/nginx/sites-available/default.dpkg-dist similarity index 100% rename from post-install/nginx/sites-available/default.dpkg-dist rename to todo/nginx/sites-available/default.dpkg-dist diff --git a/post-install/nginx/sites-available/mirror.conf b/todo/nginx/sites-available/mirror.conf similarity index 100% rename from post-install/nginx/sites-available/mirror.conf rename to todo/nginx/sites-available/mirror.conf diff --git a/todo/vm-install-op2/main.yml b/todo/vm-install-op2/main.yml new file mode 100644 index 0000000..346453d --- /dev/null +++ b/todo/vm-install-op2/main.yml @@ -0,0 +1,67 @@ +--- +- name: create mirror vm + hosts: localhost + connection: local + + +start and set autostart libvirtd +$ systemctl enable --now libvirtd +$ virsh +troubleshooting: try to load the kvm module with `modprobe kvm_intel` + +create storage pool for mirror +> pool-define-as mirror dir --target="~/.local/mirror/images" +> pool-build mirror +> pool-start mirror +> pool-autostart mirror + +create virtual disks +> vol-create-as mirror mirror_root1.qcow2 10G +> vol-create-as mirror mirror_root2.qcow2 10G +> vol-create-as mirror mirror_disk1.qcow2 5G +> vol-create-as mirror mirror_disk2.qcow2 5G +> vol-create-as mirror mirror_disk3.qcow2 5G +> vol-create-as mirror mirror_disk4.qcow2 5G +(exit virsh shell) + +get ubuntu iso +$ curl -O https://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso + +create the vm +$ virt-install \ +--name=mirror \ +--memory=2048 \ +--vcpus=1 \ +--boot uefi \ +--location="./ubuntu-20.04.2-live-server-amd64.iso" \ +--disk vol=mirror/mirror_root1.qcow2 \ +--disk vol=mirror/mirror_root2.qcow2 \ +--disk vol=mirror/mirror_disk1.qcow2 \ +--disk vol=mirror/mirror_disk2.qcow2 \ +--disk vol=mirror/mirror_disk3.qcow2 \ +--disk vol=mirror/mirror_disk4.qcow2 \ + +interface should automatically come up but can also use +$ virt-viewer --domain-name mirror +if vm is on a remote machine +$ virt-viewer --connect qemu+ssh://user@host.example.com/system vmnamehere + +for now just have a folder of screenshots +- change name of lvm volume from "lv0-root" to just "root" +troubleshooting: ignore "failed to unmount /cdrom" and just ctrl+c in viewer + +login into your created user (from install), change to root, and create password for root +$ sudo su +type in your password +$ passwd +create root password + +create zpool (use /dev/disk/by-id/.. instead) +$ apt update +$ apt install zfsutils-linux nginx rsync +$ mkdir -p /mirror/root/.cscmirror +$ zpool create -f -m /mirror/root/.cscmirror cscmirror raidz2 /dev/vdc /dev/vdd /dev/vde /dev/vdf + +may already be mounted but just to be sure +$ zfs mount -a + diff --git a/todo/vm-install-op2/mirror.txt b/todo/vm-install-op2/mirror.txt new file mode 100644 index 0000000..89fc986 --- /dev/null +++ b/todo/vm-install-op2/mirror.txt @@ -0,0 +1,95 @@ +remarks +- vm will not have autostart +- storage req: 40GB + - root size: 10GB (x2 for raid 1) + - storage size: 5GB (x4 for raid-z2) + +install (debian) +$ apt install qemu-kvm libvirt virt-install virt-viewer + +install (arch) +$ pacman -S qemu libvirt virt-install virt-viewer + +start and set autostart libvirtd +$ systemctl enable --now libvirtd +$ virsh +troubleshooting: try to load the kvm module with `modprobe kvm_intel` + +create storage pool for mirror +> pool-define-as mirror dir --target="~/.local/mirror/images" +> pool-build mirror +> pool-start mirror +> pool-autostart mirror + +create virtual disks +> vol-create-as mirror mirror_root1.qcow2 10G +> vol-create-as mirror mirror_root2.qcow2 10G +> vol-create-as mirror mirror_disk1.qcow2 5G +> vol-create-as mirror mirror_disk2.qcow2 5G +> vol-create-as mirror mirror_disk3.qcow2 5G +> vol-create-as mirror mirror_disk4.qcow2 5G +(exit virsh shell) + +get ubuntu iso +$ curl -O https://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso + +create the vm +$ virt-install \ +--name=mirror \ +--memory=2048 \ +--vcpus=1 \ +--boot uefi \ +--location="./ubuntu-20.04.2-live-server-amd64.iso" \ +--disk vol=mirror/mirror_root1.qcow2 \ +--disk vol=mirror/mirror_root2.qcow2 \ +--disk vol=mirror/mirror_disk1.qcow2 \ +--disk vol=mirror/mirror_disk2.qcow2 \ +--disk vol=mirror/mirror_disk3.qcow2 \ +--disk vol=mirror/mirror_disk4.qcow2 \ + +interface should automatically come up but can also use +$ virt-viewer --domain-name mirror +if vm is on a remote machine +$ virt-viewer --connect qemu+ssh://user@host.example.com/system vmnamehere + +for now just have a folder of screenshots +- change name of lvm volume from "lv0-root" to just "root" +troubleshooting: ignore "failed to unmount /cdrom" and just ctrl+c in viewer + +login into your created user (from install), change to root, and create password for root +$ sudo su +type in your password +$ passwd +create root password + +create zpool (use /dev/disk/by-id/.. instead) +$ apt update +$ apt install zfsutils-linux nginx rsync +$ mkdir -p /mirror/root/.cscmirror +$ zpool create -f -m /mirror/root/.cscmirror cscmirror raidz2 /dev/vdc /dev/vdd /dev/vde /dev/vdf + +may already be mounted but just to be sure +$ zfs mount -a + + +TODO +- configure symlinking from /mirror/root/.cscmirror to /mirror/root +- configure ssh for push sync +- configure nginx +- configure rsync +- set motd? +- configure FTP (using proftpd) +- Merlin in ~mirror/merlin -> /home/mirror/merlin +- ~mirror/merlin/arthur.py status +- ~mirror/merlin/arthur.py sync:PROJECT_NAME +- Sync Scripts in ~mirror/bin (and repo, but repo has less) + - take params local_dir rsync_host rsync_dir +- check out csclub wiki mirror administration for adding a new project and project sync + + +- ask if can ignore /mirror/newroot +- mirror hosts + - http://mirror.csclub.uwaterloo.ca (the mirror) + - http://ca.releases.ubuntu.com (ubuntu releases) + - http://ca.ceph.com (ceph releases) + - http://debian.csclub.uwaterloo.ca (csclub's debian packages) diff --git a/todo/vm-install-op2/mirrornetwork.xml b/todo/vm-install-op2/mirrornetwork.xml new file mode 100644 index 0000000..6aa9f1b --- /dev/null +++ b/todo/vm-install-op2/mirrornetwork.xml @@ -0,0 +1,14 @@ + + mirbr0 + + + + + + + + + + + + diff --git a/todo/vm-install-op2/thing b/todo/vm-install-op2/thing new file mode 100644 index 0000000..be9a1d8 --- /dev/null +++ b/todo/vm-install-op2/thing @@ -0,0 +1,30 @@ +create network and storage interface? + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +