ansible-edda/playbooks/tasks/services/setup/01-zfs-datasets.yml

49 lines
1.1 KiB
YAML
Raw Normal View History

- name: Create service dataset
zfs:
name: rpool/var/lib/{{ ansible_hostname }}
state: present
- name: Create a zvol for containers
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/containers
state: present
extra_zfs_properties:
volsize: "100G"
refreservation: "none"
- name: Format zvol with ext4
filesystem:
dev: /dev/rpool/var/lib/{{ ansible_hostname }}/containers
fstype: ext4
register: zvol_format
- block:
- name: Get UUID of zvol
command: blkid -s UUID -o value /dev/rpool/var/lib/{{ ansible_hostname }}/containers
register: zvol_uuid
- name: Add fstab entry and mount zvol
mount:
path: /var/lib/{{ ansible_hostname }}/containers
src: UUID={{ zvol_uuid.stdout }}
fstype: ext4
state: mounted
when:
zvol_format is changed
- name: Create service data dataset
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/data
state: present
extra_zfs_properties:
canmount: "off"
- name: Create service home dataset
zfs:
name: rpool/var/lib/{{ ansible_hostname }}/home
state: present
extra_zfs_properties:
canmount: "off"