fix libvirt playbook

autoautoinstall
Andrew Wang 1 year ago
parent 98c4b94cd4
commit 10a1a8a5aa
  1. 16
      README.md
  2. 32
      libvirt/main.yml
  3. 5
      roles/system/tasks/main.yml

@ -55,10 +55,20 @@ password: ubuntu
## VM Install Option 2 (libvirt)
### Install Packages (debian)
**needs update**
Install QEMU and KVM
```
$ apt install --no-install-recommends qemu-system libvirt-clients libvirt-daemon-system
```
Install other packages for the playbook
```
$ apt install ansible cloud-image-utils dnsmasq ovmf
```
Other packages that you probably don't need
```
$ apt install qemu-kvm libvirt-daemon virt-manager virt-viewer ansible cloud-image-utils
qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager
virtinst
virt-viewer
virt-manager
bridge-utils
```
### Install Packages (archlinux)

@ -1,24 +1,22 @@
---
- name: setup mirror vm
hosts: 127.0.0.1
gather_facts: false
tasks:
- name: mirbr0 network exists
command: "virsh net-dumpxml mirbr0 > /dev/null 2>&1"
check_mode: yes
command: "virsh net-dumpxml mirbr0"
changed_when: false
ignore_errors: true
register: net_exists
- name: storage pool exists
command: "virsh pool-dumpxml mirror > /dev/null 2>&1"
check_mode: yes
command: "virsh pool-dumpxml mirror"
changed_when: false
ignore_errors: true
register: pool_exists
- name: mirror vm exists
command: "virsh dumpxml mirror > /dev/null 2>&1"
check_mode: yes
command: "virsh dumpxml mirror"
changed_when: false
ignore_errors: true
register: vm_exists
@ -51,7 +49,7 @@
- net-define {{ playbook_dir }}/templates/network.xml
- net-autostart mirbr0
- net-start mirbr0
when: not net_exists.rc == 0
when: net_exists.rc != 0
- name: create storage pool
command: "virsh {{ item }}"
@ -60,7 +58,7 @@
- pool-build mirror
- pool-autostart mirror
- pool-start mirror
when: not pool_exists.rc == 0
when: pool_exists.rc != 0
# hardcoded to 10G since modification would require change to user-data
- name: create virtual disks
@ -75,6 +73,8 @@
- { name: mirror_disk3.qcow2, size: 10G }
- { name: mirror_disk4.qcow2, size: 10G }
# does not exist yet
# --os-variant ubuntu20.04
- name: create vm
command: >
virt-install
@ -82,7 +82,7 @@
--memory=2048
--vcpus=1
--boot uefi
--os-type linux --os-variant ubuntu20.04
--os-type linux
--disk path={{ playbook_dir }}/vm/seed.qcow2,device=cdrom
--disk vol=mirror/mirror_root1.qcow2
--disk vol=mirror/mirror_root2.qcow2
@ -93,7 +93,7 @@
--network bridge=mirbr0
--graphics vnc,port=5911,listen=127.0.0.1
--noautoconsole
when: not vm_exists.rc == 0
when: vm_exists.rc != 0
# get user to set net.ipv4.ip_forward = 1 ?
# in the vm to disable cloud-init run
@ -103,6 +103,18 @@
# 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

@ -92,8 +92,7 @@
disk_arg: "{{ disks | join(' ') }}"
- name: zpool exists
command: "zpool status cscmirror > /dev/null 2>&1"
check_mode: yes
command: "zpool status cscmirror"
changed_when: false
ignore_errors: true
register: zpool_exists
@ -105,7 +104,7 @@
cscmirror
raidz2
{{ disk_arg }}
when: not zpool_exists.rc == 0
when: zpool_exists.rc != 0
# mount all zpools
# zfs mount -a

Loading…
Cancel
Save