give up on autoinstall

This commit is contained in:
Andrew Wang 2021-09-27 22:49:49 -04:00
parent c1fb658ba3
commit 77a72eb11b
8 changed files with 50 additions and 158 deletions

24
libvirt/README.md Normal file
View File

@ -0,0 +1,24 @@
then service libvirtd restart
adduser <youruser> libvirt
adduser -aG <youruser> libvirt
To create the vm run the command
```
ansible-playbook main.yml
```
## Troubleshooting
```
net.ipv4.ip_forward = 1 ?
```
```
modprobe kvm_intel
```
If running in `/root` may need to edit config
```
# edit /etc/libvirt/qemu.conf
user = "root"
group = "root"
$ service restart libvirtd
```

View File

@ -29,13 +29,13 @@
- name: fetch ubuntu iso
get_url:
# url: "https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso"
# dest: "{{ playbook_dir }}/vm/ubuntu20_04.iso"
url: "http://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"
dest: "{{ playbook_dir }}/vm/focal-server-cloudimg-amd64.img"
url: "https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso"
dest: "{{ playbook_dir }}/vm/ubuntu20_04.iso"
# Installing VMs from Ready Images
# https://www.x386.xyz/index.php/2021/01/06/kvm-on-ubuntu-server-1/
# autoinstall not working for libvirt
# https://manintheit.org/en/posts/automation/ubuntu-autoinstall/
# https://ubuntu.com/server/docs/install/autoinstall-quickstart
#
# --network-config {{ playbook_dir }}/templates/network
# - name: create ubuntu iso seed
# command:
@ -55,19 +55,6 @@
# {{ playbook_dir }}/templates/meta-data
# creates: "{{ playbook_dir }}/vm/seed.iso"
# # ???
# - name: create new image
# command:
# cmd: >
# qemu-img create
# -b {{ playbook_dir }}/focal-server-cloudimg-amd64.img
# -f qcow2
# -F qcow2
# {{ playbook_dir }}/vm/mirror.img
# creates: "{{ playbook_dir }}/vm/mirror.img"
- name: create mirbr0 bridge network
command: "virsh {{ item }}"
loop:
@ -85,7 +72,7 @@
- pool-start mirror
when: pool_exists.rc != 0
# hardcoded to 10G since modification would require change to user-data
# TODO: allow user to create any number of disks with any size
- name: create virtual disks
command:
cmd: "virsh vol-create-as mirror {{ item.name }} {{ item.size }}"
@ -103,6 +90,8 @@
# --cdrom path={{ playbook_dir }}/vm/ubuntu20_04.iso
# --disk path={{ playbook_dir }}/vm/seed.iso,format=raw,bus=virtio
# --cloud-init user-data={{ playbook_dir }}/templates/user-data,meta-data={{ playbook_dir }}/templates/meta-data
# --disk path={{ playbook_dir }}/vm/focal-server-cloudimg-amd64.img
- name: create vm
command: >
virt-install
@ -111,8 +100,7 @@
--vcpus=1
--boot uefi
--os-type linux
--cloud-init user-data={{ playbook_dir }}/templates/user-data, meta-data={{ playbook_dir }}/templates/meta-data
--disk path={{ playbook_dir }}/vm/focal-server-cloudimg-amd64.img
--cdrom {{ playbook_dir }}/vm/ubuntu20_04.iso
--disk vol=mirror/mirror_root1.qcow2,bus=virtio
--disk vol=mirror/mirror_root2.qcow2,bus=virtio
--disk vol=mirror/mirror_disk1.qcow2,bus=virtio
@ -123,57 +111,3 @@
--graphics vnc,port=5911,listen=127.0.0.1
--noautoconsole
when: vm_exists.rc != 0
# get user to set net.ipv4.ip_forward = 1 ?
# in the vm to disable cloud-init run
# sudo touch /etc/cloud/cloud-init.disabled
# wait ? seconds (hope that vm is made in foreground)
# copy over pub key into /root/.ssh/authorized_keys
# add line to ssh config that allows ssh as root
# modprobe kvm_intel
# depending on where you are installing may need to edit
# /etc/libvirt/qemu.conf
# user = "root"
# group = "root"
# then service libvirtd restart
# adduser <youruser> libvirt
# adduser -aG <youruser> libvirt
# this should execute in order right?
- name: setup mirror vm
hosts: 192.168.123.2
# - modify ssh config to allow root login
# - copy over ssh public keys (if provided)
roles:
- "../roles/system"
- "../roles/mirror"
# - "../roles/ftp"
# - "../roles/nginx"
# - "../roles/rsync"
# tasks:
# allow root login from here
# become: root
# loop does not work...
# - name: setup system
# import_role:
# name: "../roles/system"
# - name: setup mirror
# import_role:
# name: "../roles/mirror"
# - name: setup ftp
# import_role:
# name: "../roles/ftp"
# - name: setup nginx
# import_role:
# name: "../roles/nginx"
# - name: setup rsync
# import_role:
# name: "../roles/rsync"
# - name: setup rsync
# import_role: "../roles/mirrormanager"

View File

@ -1,12 +0,0 @@
#cloud-config
version: 2
ethernets:
enp1s0:
dhcp4: false
addresses: [ 192.168.123.2/24 ]
gateway4: 192.168.123.1
nameservers:
addresses: [ 1.1.1.1 ]
# set up static ip
# https://askubuntu.com/questions/1029531/how-to-setup-a-static-ip-on-ubuntu-server-18-04

View File

@ -1,62 +0,0 @@
#cloud-config
autoinstall:
version: 1
identity:
hostname: mirror
username: local
# mkpasswd --method=SHA-512 --rounds=4096
# password is krb5
password: "$6$rounds=4096$FfXwns8mexFJUAjS$z/ERS/5gitnl8f3AZnnztS8iFpmS/AtzUfEVM2.tfRpWnl/y7PwhDZTeT68WxoogmSTgaZyVL6..jP4aiB1LD0"
# this password is ubuntu
# $6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0
locale: en_US
ssh:
allow-pw: true
authorized-keys: []
install-server: true
storage:
config:
# disks =-=-=-=-=-=-=
- {id: vda, name: '', path: /dev/vda, type: disk, ptable: gpt,
preserve: false, grub_device: false}
- {id: vdb, name: '', path: /dev/vdb, type: disk, ptable: gpt,
preserve: false, grub_device: false}
# partitions =-=-=-=-=-=
# vda1
- {id: vda1, type: partition, size: 500M, device: vda, number: 1,
preserve: false, wipe: superblock, flag: boot, grub_device: true}
- {id: vda1-format, type: format, volume: vda1,
fstype: fat32, preserve: false}
# vda2
- {id: vda2, type: partition, size: 9G, device: vda, number: 2,
preserve: false, wipe: superblock, flag: '', grub_device: false}
# vdb1
- {id: vdb1, type: partition, size: 500M, device: vdb, number: 1,
preserve: false, wipe: superblock, flag: boot, grub_device: true}
- {id: vdb1-format, type: format, volume: vdb1,
fstype: fat32, preserve: false}
# vdb2
- {id: vdb2, type: partition, size: 9G, device: vdb, number: 2,
preserve: false, wipe: superblock, flag: '', grub_device: false}
# raid =-=-=-=-=-=
- id: md0
name: md0
type: raid
raidlevel: raid1
devices: [vda2, vdb2]
spare_devices: []
preserve: false
# lvm =-=-=-=-=-=
- id: vg0
name: vg0
type: lvm_volgroup
devices: [md0]
preserve: false
# partition
- {id: vg0-root, name: root, type: lvm_partition, size: 8G,
preserve: false, volgroup: vg0}
- {id: vg0-root-format, type: format, volume: vg0-root,
fstype: ext4, preserve: false}
# mount points =-=-=-=-=-=
- {id: boot-mount, type: mount, path: /boot/efi, device: vda1-format}
- {id: root-mount, type: mount, path: /, device: vg0-root-format}

View File

@ -1,7 +0,0 @@
# local playbook
this playbook will be run inside a already set up vm to set up the services
used if someone wants to set up vm themselves + wants more disks in the pool
includes varable for which disks to turn into a zfs pool

4
mirror/README.md Normal file
View File

@ -0,0 +1,4 @@
# mirror playbook
this playbook will be run inside a already set up vm to set up the services
TODO: varable for which disks to turn into a zfs pool

11
mirror/main.yml Normal file
View File

@ -0,0 +1,11 @@
- name: setup mirror vm
hosts: 127.0.0.1
# - modify ssh config to allow root login
# - copy over ssh public keys (if provided)
roles:
- "../roles/system"
- "../roles/mirror"
# - "../roles/ftp"
# - "../roles/nginx"
# - "../roles/rsync"
# TODO: - "../roles/mirrormanager"