summaryrefslogtreecommitdiff
path: root/roles/zfs/base/tasks/main.yml
blob: e86b974b33fd765a8eefdee1d81af24aa76c3d21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
- name: configure arc size
  when: zfs_arc_size is defined
  copy:
    content: |
      options zfs zfs_arc_min={{ zfs_arc_size.min }}
      options zfs zfs_arc_max={{ zfs_arc_size.max }}
    dest: /etc/modprobe.d/zfs.conf

- name: install zfs modules
  include_tasks: "{{ ansible_distribution }}.yml"

- name: load zfs kernel module
  modprobe:
    name: zfs
    state: present

- name: install zed and zfs file system utilities
  apt:
    name:
      - zfsutils-linux
      - zfs-zed
    state: present

- name: enable zfs-list-cacher zlet for systemd zfs-mount-generator
  file:
    src: /usr/lib/zfs-linux/zed.d/history_event-zfs-list-cacher.sh
    dest: /etc/zfs/zed.d/history_event-zfs-list-cacher.sh
    state: link

- name: create base-directory for zfs-list.cache
  file:
    path: /etc/zfs/zfs-list.cache/
    state: directory

- name: create zfs-list.cache file for zpools
  loop: "{{ zfs_zpools | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  copy:
    content: ""
    dest: "/etc/zfs/zfs-list.cache/{{ item.key }}"
    force: no

- name: create zpools
  loop: "{{ zfs_zpools | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  command: "zpool create -m {{ item.value.mountpoint }} {% for prop, value in (item.value.properties | default(zfs_zpool_properties)).items() %}-o {{ prop }}={{ value }} {% endfor %}{{ item.key }} {{ item.value.create_vdevs }}"
  args:
    creates: "{{ item.value.mountpoint }}"