libvirt fixes
This commit is contained in:
parent
283c3fc6b8
commit
a1da443418
|
@ -48,17 +48,18 @@ ansible-playbook qemu-vm.yml
|
|||
|
||||
### 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)
|
||||
```
|
||||
$ pacman -S qemu libvirt virt-install virt-viewer ansible
|
||||
$ pacman -S qemu libvirt virt-install virt-viewer ansible
|
||||
```
|
||||
|
||||
### Run Playbook
|
||||
```
|
||||
ansible-playbook kvm-vm.yml
|
||||
ansible-playbook libvirt/main.yml
|
||||
```
|
||||
|
||||
## Post-Installation
|
||||
|
|
14
hosts
14
hosts
|
@ -1,14 +1,8 @@
|
|||
[vm]
|
||||
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
|
||||
|
||||
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
|
||||
# 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]
|
||||
localhost ansible_connection=local
|
||||
127.0.0.1 ansible_connection=local
|
|
@ -1,30 +1,33 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
- name: setup mirror vm
|
||||
hosts: 127.0.0.1
|
||||
tasks:
|
||||
- name: gather facts
|
||||
- name: ubuntu iso exists
|
||||
stat:
|
||||
path: "{{ playbook_dir }}/vm/ubuntu20_04.iso"
|
||||
register: iso_exists
|
||||
ignore_errors: true
|
||||
tasks:
|
||||
- name: ubuntu iso exists
|
||||
stat:
|
||||
path: "{{ playbook_dir }}/vm/ubuntu20_04.iso"
|
||||
register: iso_exists
|
||||
|
||||
- name: ubuntu iso seed exists
|
||||
stat:
|
||||
path: "{{ playbook_dir }}/vm/seed.qcow2"
|
||||
register: seed_exists
|
||||
- name: ubuntu iso seed exists
|
||||
stat:
|
||||
path: "{{ playbook_dir }}/vm/seed.qcow2"
|
||||
register: seed_exists
|
||||
ignore_errors: true
|
||||
|
||||
- name: mirror vm exists
|
||||
command: "virsh dumpxml mirror > /dev/null 2>&1"
|
||||
register: vm_exists
|
||||
- name: mirror vm exists
|
||||
command: "virsh dumpxml mirror > /dev/null 2>&1"
|
||||
register: vm_exists
|
||||
ignore_errors: true
|
||||
|
||||
- name: storage pool exists
|
||||
command: "virsh pool-dumpxml mirror > /dev/null 2>&1"
|
||||
register: pool_exists
|
||||
- name: storage pool exists
|
||||
command: "virsh pool-dumpxml mirror > /dev/null 2>&1"
|
||||
register: pool_exists
|
||||
ignore_errors: true
|
||||
|
||||
- name: mirbr0 network exists
|
||||
command: "virsh net-dumpxml mirbr0 > /dev/null 2>&1"
|
||||
register: net_exists
|
||||
- name: mirbr0 network exists
|
||||
command: "virsh net-dumpxml mirbr0 > /dev/null 2>&1"
|
||||
register: net_exists
|
||||
ignore_errors: true
|
||||
|
||||
- name: create directory for vm
|
||||
file:
|
||||
|
@ -71,6 +74,7 @@
|
|||
|
||||
# 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
|
||||
# could just check for each if they are created
|
||||
- name: create virtual disks
|
||||
command: "virsh vol-create-as mirror {{ item }}"
|
||||
with_items:
|
||||
|
@ -107,8 +111,11 @@
|
|||
# copy over pub key into /root/.ssh/authorized_keys
|
||||
# add line to ssh config that allows ssh as root
|
||||
|
||||
- hosts: 192.168.123.2
|
||||
roles:
|
||||
# roles are called relative to playbook
|
||||
- name: setup mirror services
|
||||
hosts: 192.168.123.2
|
||||
include_role: "../roles/{{ item }}"
|
||||
with_items:
|
||||
- zfs
|
||||
# - index
|
||||
# - nginx
|
||||
|
|
Loading…
Reference in New Issue