libvirt config

This commit is contained in:
2022-09-05 21:27:26 +12:00
parent 140749e34c
commit 1166e932c5
9 changed files with 166 additions and 43 deletions

View File

@ -6,6 +6,8 @@ libvirt_server_packages:
- openbsd-netcat
- edk2-ovmf
- swtpm
- libvirt-python
- python-lxml
libvirt_zfs_pool_name: zfs
libvirt_zfs_pool_path: ssd/vhds

View File

@ -5,7 +5,6 @@
name: "{{ libvirt_server_packages }}"
state: latest
update_cache: true
reason: explicit
when:
- ansible_os_family == 'Arch'
@ -23,9 +22,12 @@
state: started
enabled: yes
- name: set cluster network variables
set_fact:
libvirt_network_name: "{{ libvirt_cluster_network_name }}"
libvirt_network_domain: "{{ libvirt_cluster_network_name }}"
- name: define vm cluster network
libvirt_network_name: "{{ libvirt_cluster_network_name }}"
libvirt_network_domain: "{{ libvirt_cluster_network_name }}"
community.libvirt.virt_net:
name: "{{ libvirt_cluster_network_name }}"
command: define
@ -34,7 +36,7 @@
- name: build vm cluster network
community.libvirt.virt_net:
name: "{{ libvirt_cluster_network_name }}"
command: build
command: create
- name: start vm cluster network
community.libvirt.virt_net:
@ -52,32 +54,36 @@
name: "{{ libvirt_zfs_pool_path }}"
state: present
extra_zfs_properties:
- canmount: off
- mountpoint: none
- compression: off
- primarycache: metadata
- secondarycache: none
- reservation: none
- refreservation: none
- dedup: off
- encryption: off
- volmode: dev
- devices: off
- atime: off
canmount: off
mountpoint: none
compression: off
primarycache: metadata
secondarycache: none
reservation: none
refreservation: none
dedup: off
encryption: off
volmode: dev
devices: off
atime: off
- name: set zfs pool variables
set_fact:
libvirt_pool_type: zfs
libvirt_pool_name: "{{ libvirt_zfs_pool_name }}"
libvirt_pool_source: "{{ libvirt_zfs_pool_path }}"
libvirt_pool_target: ""
- name: define zfs storage pool
libvirt_pool_type: zfs
libvirt_pool_name: "{{ libvirt_zfs_pool_name }}"
libvirt_pool_path: "{{ libvirt_zfs_pool_path }}"
community.libvirt.virt_pool:
name: "{{ libvirt_zfs_pool_name }}"
command: define
xml: '{{ lookup("template", "pool.xml.j2") }}'
- name: build zfs storage pool
community.libvirt.virt_pool:
name: "{{ libvirt_zfs_pool_name }}"
command: build
# - name: build zfs storage pool
# community.libvirt.virt_pool:
# name: "{{ libvirt_zfs_pool_name }}"
# command: build
- name: start zfs storage pool
community.libvirt.virt_pool:
@ -85,6 +91,13 @@
state: active
autostart: true
- name: set iso pool variables
set_fact:
libvirt_pool_type: dir
libvirt_pool_name: "{{ libvirt_iso_pool_name }}"
libvirt_pool_source: ""
libvirt_pool_target: "{{ libvirt_iso_pool_path }}"
- name: create iso storage dir
become: true
ansible.builtin.file:
@ -95,9 +108,6 @@
mode: 0775
- name: define iso storage pool
libvirt_pool_type: dir
libvirt_pool_name: "{{ libvirt_iso_pool_name }}"
libvirt_pool_path: "{{ libvirt_iso_pool_path }}"
community.libvirt.virt_pool:
name: "{{ libvirt_iso_pool_name }}"
command: define
@ -114,6 +124,13 @@
state: active
autostart: true
- name: set iso pool variables
set_fact:
libvirt_pool_type: dir
libvirt_pool_name: "{{ libvirt_qcow_pool_name }}"
libvirt_pool_source: ""
libvirt_pool_target: "{{ libvirt_qcow_pool_path }}"
- name: create qcow storage dir
become: true
ansible.builtin.file:
@ -124,9 +141,6 @@
mode: 0775
- name: define qcow storage pool
libvirt_pool_type: dir
libvirt_pool_name: "{{ libvirt_qcow_pool_name }}"
libvirt_pool_path: "{{ libvirt_qcow_pool_path }}"
community.libvirt.virt_pool:
name: "{{ libvirt_qcow_pool_name }}"
command: define

View File

@ -1,6 +1,9 @@
<pool type="{{ libvirt_pool_type }}">
<name>{{ libvirt_pool_name }}</name>
<source>
<name>{{ libvirt_pool_path }}</name>
<name>{{ libvirt_pool_source }}</name>
</source>
<target>
<path>{{ libvirt_pool_target }}</path>
</target>
</pool>