add cleanup playbook for libvirt
This commit is contained in:
parent
0204237618
commit
2834d86e92
|
@ -16,6 +16,7 @@ Follow instructions in the [readme](qemu/README.md) of the qemu directory.
|
||||||
Follow the instructions in [readme](libvirt/README.md) of the libirt directory.
|
Follow the instructions in [readme](libvirt/README.md) of the libirt directory.
|
||||||
|
|
||||||
## Issues/Remarks
|
## Issues/Remarks
|
||||||
|
- vm is set to autostart when installing using libvirt playbook
|
||||||
- cron config `/etc/cron.d/csc-mirror` is commented out for now
|
- cron config `/etc/cron.d/csc-mirror` is commented out for now
|
||||||
- merlin.service is NOT started
|
- merlin.service is NOT started
|
||||||
- outsider/insider
|
- outsider/insider
|
||||||
|
|
|
@ -26,9 +26,8 @@ $ pacman -S qemu libvirt virt-install virt-viewer ansible
|
||||||
```
|
```
|
||||||
## Running the Playbook
|
## Running the Playbook
|
||||||
|
|
||||||
Run the playbook from one directory down
|
|
||||||
```
|
```
|
||||||
ansible-playbook -K libvirt/main.yml
|
ansible-playbook -K main.yml
|
||||||
```
|
```
|
||||||
Then connect to the created vm using virt-viewer
|
Then connect to the created vm using virt-viewer
|
||||||
```
|
```
|
||||||
|
@ -67,6 +66,14 @@ $ apt install git ansible
|
||||||
$ git clone https://git.csclub.uwaterloo.ca/public/mirror-env.git
|
$ git clone https://git.csclub.uwaterloo.ca/public/mirror-env.git
|
||||||
```
|
```
|
||||||
Then enter `mirror-env/mirror` and follow the instructions there.
|
Then enter `mirror-env/mirror` and follow the instructions there.
|
||||||
|
|
||||||
|
## Deleting the VM
|
||||||
|
|
||||||
|
The VM and everything related can be removed by running the `cleanup.yml` playbook
|
||||||
|
```
|
||||||
|
ansible-playbook -K cleanup.yml
|
||||||
|
```
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -75,7 +82,7 @@ net.ipv4.ip_forward = 1
|
||||||
```
|
```
|
||||||
modprobe kvm_intel
|
modprobe kvm_intel
|
||||||
```
|
```
|
||||||
If running in `/root` may need to edit config
|
If running as `root` may need to edit config
|
||||||
```
|
```
|
||||||
# edit /etc/libvirt/qemu.conf
|
# edit /etc/libvirt/qemu.conf
|
||||||
user = "root"
|
user = "root"
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
---
|
||||||
|
- name: delete the mirror vm
|
||||||
|
hosts: 127.0.0.1
|
||||||
|
gather_facts: no
|
||||||
|
become: yes
|
||||||
|
tasks:
|
||||||
|
- name: mirbr0 network exists
|
||||||
|
command: "virsh net-dumpxml mirbr0"
|
||||||
|
changed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
register: net_exists
|
||||||
|
|
||||||
|
- name: storage pool exists
|
||||||
|
command: "virsh pool-dumpxml mirror"
|
||||||
|
changed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
register: pool_exists
|
||||||
|
|
||||||
|
- name: mirror vm exists
|
||||||
|
command: "virsh dumpxml mirror"
|
||||||
|
changed_when: false
|
||||||
|
ignore_errors: true
|
||||||
|
register: vm_exists
|
||||||
|
|
||||||
|
- name: delete vm
|
||||||
|
command: "virsh {{ item }}"
|
||||||
|
loop:
|
||||||
|
- destroy mirror
|
||||||
|
- undefine mirror
|
||||||
|
when: vm_exists.rc == 0
|
||||||
|
|
||||||
|
- name: delete storage pool
|
||||||
|
command: "virsh {{ item }}"
|
||||||
|
loop:
|
||||||
|
- pool-destroy mirror
|
||||||
|
- pool-undefine mirror
|
||||||
|
when: pool_exists.rc == 0
|
||||||
|
|
||||||
|
- name: delete mirbr0 bridge network
|
||||||
|
command: "virsh {{ item }}"
|
||||||
|
loop:
|
||||||
|
- net-destroy mirbr0
|
||||||
|
- net-undefine mirbr0
|
||||||
|
when: net_exists.rc == 0
|
||||||
|
|
||||||
|
- name: delete directory for vm
|
||||||
|
file:
|
||||||
|
path: "{{ playbook_dir }}/vm"
|
||||||
|
state: absent
|
|
@ -2,6 +2,7 @@
|
||||||
- name: setup mirror vm
|
- name: setup mirror vm
|
||||||
hosts: 127.0.0.1
|
hosts: 127.0.0.1
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
become: yes
|
||||||
tasks:
|
tasks:
|
||||||
- name: mirbr0 network exists
|
- name: mirbr0 network exists
|
||||||
command: "virsh net-dumpxml mirbr0"
|
command: "virsh net-dumpxml mirbr0"
|
||||||
|
|
Loading…
Reference in New Issue