deploy-base/roles/zfs/tasks/main.yml

78 lines
2 KiB
YAML

---
# temporarily added to test zfs role by itself
#- name: check if atomic
# stat:
# path: /run/ostree-booted
# register: ostree
#
#- name: set fact (atomic state)
# set_fact:
# is_atomic: "{{ ostree.stat.exists }}"
# end temp additions
- name: install zfs-release package (RHEL/CentOS)
yum:
name: "http://download.zfsonlinux.org/epel/zfs-release.el7_5.noarch.rpm"
state: present
when: ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux" ]
- name: install zfs-release package (Fedora)
dnf:
name: "http://download.zfsonlinux.org/fedora/zfs-release.fc29.noarch.rpm"
state: present
when: ansible_distribution in ["Fedora"] and not is_atomic
- name: install zfs utils (Ubuntu)
package:
name: "{{ item }}"
state: present
with_items:
- zfsutils-linux
- zfs-initramfs
when: ansible_distribution in ["Ubuntu"]
- name: install zfs and dkms
package:
name: "{{ item }}"
state: present
with_items:
- kernel-devel
- "@Development tools"
- dkms
- zfs
register: zfs_installed
when: ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux", "Fedora" ] and not is_atomic
- name: load zfs module
modprobe:
name: zfs
state: present
- name: add zfs to modules-load.d
copy:
dest: "/etc/modules-load.d/zfs.conf"
content: |
zfs
register: zfsload
# does not adjust to 20% of each host, depends on consistency between hosts - inconsistency leads to disproportionate allocations
- name: set zfs_arc_max to 20% installed memory ({{ zfs_arc_size_bytes }} bytes)
lineinfile:
path: "/etc/modprobe.d/zfs.conf"
regexp: '^options zfs zfs_arc_max='
line: 'options zfs zfs_arc_max="{{ zfs_arc_size_bytes }}"'
create: yes
- name: check for data pool
command: "zpool list"
register: pools
#ignore_errors: true
changed_when: pools.stdout.find('data') != -1
- zpool_facts: properties='all'
# really bad idempotence in here...
- name: create zpool
command: "zpool create -f -O compression=lz4 data {{ zfs_disk }} -o ashift=13 -O secondarycache=all"
when: not pools.changed