moved back to group_vars

This commit is contained in:
Daniel Liu 2021-09-26 00:46:38 -04:00
parent 1f966eedd0
commit 5cee6914d5
4 changed files with 36 additions and 86 deletions

View File

@ -1,37 +1,49 @@
# Mirror Env # Mirror Env
This script helps quickly set up a vm development environment for cs club's mirrors. This repo helps quickly set up a vm development environment for cs club's
mirrors using ansible.
## VM Installation Option 1 (qmeu-vm.yml) There are three options for getting the mirror dev vm running:
- qemu
- libvirt
- manual
**instructions need to be rewritten** Follow the relevant instructions below.
Install the following dependencies ## VM Installation Option 1 (qmeu)
Install the following:
- ansible
- qemu - qemu
- genisoimage - genisoimage
- ovmf (find the location of OVMF\_CODE.fd, it is system dependent) - ovmf (find the location of OVMF\_CODE.fd, it is system dependent)
Edit the configuration variables in the script file to reflect your system. Before doing anything else, edit the config files in `group_vars/` to your
system's needs. For qemu installation specifically, you need to provide the
location of your `OVMF_CODE.fd` file.
The `mirror-vm` script will will automatically install ubuntu using the [autoinstall](https://ubuntu.com/server/docs/install/autoinstall) feature. To begin the setup process, in this repo's root, run:
``` ```
curl -O https://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso $ ansible-playbook -K qemu/main.yml
$ ./mirror-vm create
$ ./mirror-vm run-install
``` ```
To view the vm, you also need a vnc viewer. [TigerVNC](https://github.com/TigerVNC/tigervnc) is a good choice. Simply run Due to the way the ubuntu autoinstall is designed, user confirmation is
required to start the autoinstallation process. To view the vm, you also need a
vnc viewer. [TigerVNC](https://github.com/TigerVNC/tigervnc) is a good choice.
Simply run
``` ```
$ vncviewer :5900 $ vncviewer :5900
``` ```
Due to the way the ubuntu autoinstall is designed, user confirmation is required to start the autoinstallation process. Enter `yes` when prompted with this line: Enter `yes` when prompted with
this line:
``` ```
Continue with autoinstall (yes|no) Continue with autoinstall (yes|no)
``` ```
After going through the install process you can run the vm with Once the installation is complete, you can run the vm using:
``` ```
$ ./mirror-vm run $ ansible-playbook qemu/run/yml
``` ```
The default login user has The default login user has
@ -39,12 +51,8 @@ The default login user has
username: ubuntu username: ubuntu
password: ubuntu password: ubuntu
``` ```
### Run Playbook
```
ansible-playbook qemu-vm.yml
```
## VM Install Option 2 (kvm) ## VM Install Option 2 (libvirt)
### Install Packages (debian) ### Install Packages (debian)
**needs update** **needs update**
@ -64,9 +72,6 @@ $ pacman -S qemu libvirt virt-install virt-viewer ansible
ansible-playbook libvirt/main.yml ansible-playbook libvirt/main.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.
First, install ansible and sshpass. Perform all the following commands in the `post-install/` directory. First, install ansible and sshpass. Perform all the following commands in the `post-install/` directory.
Also install the extra roles Also install the extra roles
@ -83,7 +88,11 @@ We can now complete the rest of the post-install with
$ ansible-playbook -K playbook.yml $ ansible-playbook -K playbook.yml
``` ```
## VM Install Option 3 (manual)
## System Details ## System Details
Further system information for those that are interested.
``` ```
$ lsblk $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

6
group_vars/all.yml Normal file
View File

@ -0,0 +1,6 @@
---
ovmf:
vm_ram: 1G
vm_disk_size: 9G
vm_ssh_port: 22
userdata: "{{playbook_dir}}/userdata"

View File

@ -1,59 +0,0 @@
#!/bin/sh
help() {
cat << EOF
=-=-=-=-= mirror-vm =-=-=-=-=
Usage: mirror-vm [COMMAND]
Commands:
libvirt-install, li
creates and installs the mirror server
on a new vm using libvirt
qemu-install, qi
creates and installs the mirror server
on a new vm using qemu
libvirt-run, lr
runs a previously created libvirt vm
qemu-run, qr
runs a previously created qemu vm
clean, c
removes user files like your vm
help, h
prints this message
EOF
}
libvirt_install() {
ansible-playbook -K libvirt/main.yml
}
qemu_install() {
ansible-playbook -K qemu/main.yml
}
libvirt_run() {
echo 'libvirt-run'
}
qemu_run() {
ansible-playbook -K qemu/run.yml
}
clean() {
rm -rf qemu/vm libvirt/vm
}
case $1 in
li|libvirt-install) libvirt_install;;
qi|qemu-install) qemu_install;;
lr|libvirt-run) libvirt_run;;
qr|qemu-run) qemu_run;;
c|clean) clean;;
h|help|*) help;;
esac

View File

@ -1,12 +1,6 @@
--- ---
# Gather info # Gather info
- hosts: localhost - hosts: localhost
vars:
ovmf:
vm_ram: 1G
vm_disk_size: 9G
vm_ssh_port: 22
userdata: "{{playbook_dir}}/userdata"
tasks: tasks:
- name: Check if vm was created already - name: Check if vm was created already
stat: stat: