diff --git a/roles/bhyve-storage/tasks/main.yml b/roles/bhyve-storage/tasks/main.yml new file mode 100644 index 0000000..8287358 --- /dev/null +++ b/roles/bhyve-storage/tasks/main.yml @@ -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