82 lines
2.5 KiB
YAML
82 lines
2.5 KiB
YAML
---
|
|
|
|
# TODO: Split tasks into distribution appropriate files
|
|
# avoid running/skipping tasks entirely by not including them
|
|
|
|
# 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 (EPEL 7)
|
|
yum:
|
|
name: "http://download.zfsonlinux.org/epel/zfs-release.el7_7.noarch.rpm"
|
|
state: present
|
|
when: (ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux" ]) and (ansible_distribution_major_version == "7")
|
|
|
|
- name: install zfs-release package (EPEL 8)
|
|
yum:
|
|
name: "http://download.zfsonlinux.org/epel/zfs-release.el8_1.noarch.rpm"
|
|
state: present
|
|
when: (ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux" ]) and (ansible_distribution_major_version == "8")
|
|
|
|
- name: install zfs-release package (Fedora)
|
|
dnf:
|
|
name: "http://download.zfsonlinux.org/fedora/zfs-release.fc31.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: "{{ ZFS_PKGS | difference(ansible_facts.packages) }}"
|
|
state: present
|
|
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 and ('worker' in inventory_hostname)
|