Create (multiple) ZFS volumes per guest

This commit is contained in:
Crest 2020-09-14 01:25:20 +02:00
parent 05ec7f2022
commit e03c04873c
1 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,42 @@
---
- name: Create common bhyve datasets
zfs:
name: '{{ bhyve_pool }}/{{ item.name }}'
state: present
extra_zfs_properties: '{{ item.properties | default(omit) }}'
loop_control:
label: '{{ item.name }}'
with_items:
- name: bhyve
properties:
mountpoint: /bhyve
- name: bhyve/images
- name: bhyve/guests
properties:
volmode: dev
- name: Create bhyve guest datasets
zfs:
name: '{{ bhyve_pool }}/guests/{{ item.name }}'
state: present
loop_control:
label: '{{ item.name }}'
with_items: '{{ bhyve_guests }}'
- name: Gather facts over existing datasets
zfs_facts:
name: '{{ bhyve_pool }}/bhyve/guests'
recurse: yes
type: volume
- name: Create bhyve guest ZFS volumes
zfs:
name: '{{ bhyve_pool}}/bhyve/guests/{{ item.0.name }}/{{ item.1.name }}'
state: present
extra_zfs_properties: '{{ item.1.properties }}'
when: 'ansible_zfs_datasets | selectattr("name", "equalto", [bhyve_pool, "bhyve/guests", item.0.name, item.1.name] | join("/") ) | list | length < 1'
loop_control:
label: '{{ item.0.name }} : {{ item.1.name }}'
with_subelements:
- '{{ bhyve_guests }}'
- disks