libvirt fixes
This commit is contained in:
parent
283c3fc6b8
commit
a1da443418
|
@ -48,7 +48,8 @@ ansible-playbook qemu-vm.yml
|
||||||
|
|
||||||
### Install Packages (debian)
|
### Install Packages (debian)
|
||||||
```
|
```
|
||||||
$ apt install qemu-kvm libvirt virt-install virt-viewer ansible
|
$ 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
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Packages (archlinux)
|
### Install Packages (archlinux)
|
||||||
|
@ -58,7 +59,7 @@ $ pacman -S qemu libvirt virt-install virt-viewer ansible
|
||||||
|
|
||||||
### Run Playbook
|
### Run Playbook
|
||||||
```
|
```
|
||||||
ansible-playbook kvm-vm.yml
|
ansible-playbook libvirt/main.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
## Post-Installation
|
## Post-Installation
|
||||||
|
|
14
hosts
14
hosts
|
@ -1,14 +1,8 @@
|
||||||
[vm]
|
[vm]
|
||||||
192.168.123.2
|
192.168.123.2 host=mirror ansible_connection=ssh ansible_port=22 ansible_user=ubuntu ansible_password=ubuntu ansible_become_user=root ansible_become_password=ubuntu
|
||||||
host=mirror
|
|
||||||
ansible_connection=ssh
|
|
||||||
ansible_port=22
|
|
||||||
ansible_user=ubuntu
|
|
||||||
ansible_password=ubuntu
|
|
||||||
ansible_become_user=root
|
|
||||||
ansible_become_password=ubuntu
|
|
||||||
|
|
||||||
# ansible_ssh_private_key_file
|
# ansible_ssh_private_key_file
|
||||||
|
|
||||||
|
# guide on how to create vm manually (more control, more disks)
|
||||||
|
# another playbook that runs on such a vm and sets up all the services in roles (except zfs)
|
||||||
[local]
|
[local]
|
||||||
localhost ansible_connection=local
|
127.0.0.1 ansible_connection=local
|
|
@ -1,30 +1,33 @@
|
||||||
---
|
---
|
||||||
- hosts: localhost
|
- name: setup mirror vm
|
||||||
tasks:
|
hosts: 127.0.0.1
|
||||||
- name: gather facts
|
|
||||||
ignore_errors: true
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: ubuntu iso exists
|
- name: ubuntu iso exists
|
||||||
stat:
|
stat:
|
||||||
path: "{{ playbook_dir }}/vm/ubuntu20_04.iso"
|
path: "{{ playbook_dir }}/vm/ubuntu20_04.iso"
|
||||||
register: iso_exists
|
register: iso_exists
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
- name: ubuntu iso seed exists
|
- name: ubuntu iso seed exists
|
||||||
stat:
|
stat:
|
||||||
path: "{{ playbook_dir }}/vm/seed.qcow2"
|
path: "{{ playbook_dir }}/vm/seed.qcow2"
|
||||||
register: seed_exists
|
register: seed_exists
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
- name: mirror vm exists
|
- name: mirror vm exists
|
||||||
command: "virsh dumpxml mirror > /dev/null 2>&1"
|
command: "virsh dumpxml mirror > /dev/null 2>&1"
|
||||||
register: vm_exists
|
register: vm_exists
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
- name: storage pool exists
|
- name: storage pool exists
|
||||||
command: "virsh pool-dumpxml mirror > /dev/null 2>&1"
|
command: "virsh pool-dumpxml mirror > /dev/null 2>&1"
|
||||||
register: pool_exists
|
register: pool_exists
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
- name: mirbr0 network exists
|
- name: mirbr0 network exists
|
||||||
command: "virsh net-dumpxml mirbr0 > /dev/null 2>&1"
|
command: "virsh net-dumpxml mirbr0 > /dev/null 2>&1"
|
||||||
register: net_exists
|
register: net_exists
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
- name: create directory for vm
|
- name: create directory for vm
|
||||||
file:
|
file:
|
||||||
|
@ -71,6 +74,7 @@
|
||||||
|
|
||||||
# any way to check skip virtual disks that are already created?
|
# any way to check skip virtual disks that are already created?
|
||||||
# for now just hardcoding size as 10G since will need to mod user-data to use different values
|
# for now just hardcoding size as 10G since will need to mod user-data to use different values
|
||||||
|
# could just check for each if they are created
|
||||||
- name: create virtual disks
|
- name: create virtual disks
|
||||||
command: "virsh vol-create-as mirror {{ item }}"
|
command: "virsh vol-create-as mirror {{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
@ -107,8 +111,11 @@
|
||||||
# copy over pub key into /root/.ssh/authorized_keys
|
# copy over pub key into /root/.ssh/authorized_keys
|
||||||
# add line to ssh config that allows ssh as root
|
# add line to ssh config that allows ssh as root
|
||||||
|
|
||||||
- hosts: 192.168.123.2
|
# roles are called relative to playbook
|
||||||
roles:
|
- name: setup mirror services
|
||||||
|
hosts: 192.168.123.2
|
||||||
|
include_role: "../roles/{{ item }}"
|
||||||
|
with_items:
|
||||||
- zfs
|
- zfs
|
||||||
# - index
|
# - index
|
||||||
# - nginx
|
# - nginx
|
||||||
|
|
Loading…
Reference in New Issue