2019-02-25 21:49:51 -06:00
---
2020-04-17 19:40:13 -05:00
# TODO: Split tasks into distribution appropriate files
# avoid running/skipping tasks entirely by not including them
2019-03-30 20:10:57 -05:00
# 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
2020-04-17 19:40:13 -05:00
- name : install zfs-release package (EPEL 7)
yum :
name : "http://download.zfsonlinux.org/epel/zfs-release.el7_7.noarch.rpm"
state : present
2020-04-18 23:10:06 -05:00
when : ('zfs-release' not in ansible_facts.packages) and ((ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux" ]) and (ansible_distribution_major_version == "7"))
2020-04-17 19:40:13 -05:00
- name : install zfs-release package (EPEL 8)
2019-02-25 21:49:51 -06:00
yum :
2020-04-17 19:40:13 -05:00
name : "http://download.zfsonlinux.org/epel/zfs-release.el8_1.noarch.rpm"
2019-02-25 21:49:51 -06:00
state : present
2020-04-18 23:10:06 -05:00
when : ('zfs-release' not in ansible_facts.packages) and ((ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux" ]) and (ansible_distribution_major_version == "8"))
2019-02-25 21:49:51 -06:00
- name : install zfs-release package (Fedora)
dnf :
2020-01-07 00:35:01 -06:00
name : "http://download.zfsonlinux.org/fedora/zfs-release.fc31.noarch.rpm"
2019-02-25 21:49:51 -06:00
state : present
2020-04-18 23:10:06 -05:00
when : ('zfs-release' not in ansible_facts.packages) and (ansible_distribution in ["Fedora"] and not is_atomic)
2019-02-25 21:49:51 -06:00
2020-04-18 23:10:06 -05:00
- name : install ZFS (Ubuntu)
2019-06-13 20:56:43 -05:00
package :
2020-04-18 23:10:06 -05:00
name : "{{ UBUNTU_ZFS_PKGS | difference(ansible_facts.packages) }}"
2019-06-13 20:56:43 -05:00
state : present
when : ansible_distribution in ["Ubuntu"]
2019-02-25 21:49:51 -06:00
- name : install zfs and dkms
package :
2020-04-18 23:10:06 -05:00
name : "{{ EL_ZFS_PKGS | difference(ansible_facts.packages) }}"
2019-02-25 21:49:51 -06:00
state : present
register : zfs_installed
2019-06-13 20:56:43 -05:00
when : ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux", "Fedora" ] and not is_atomic
2019-02-25 21:49:51 -06:00
- 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
2019-03-30 20:10:57 -05:00
register : zfsload
2019-02-25 21:49:51 -06:00
2019-06-13 20:18:09 -05:00
# 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
2019-03-30 20:10:57 -05:00
2019-06-13 20:18:09 -05:00
- name : check for data pool
command : "zpool list"
2019-03-30 20:10:57 -05:00
register : pools
2019-06-13 20:18:09 -05:00
#ignore_errors: true
changed_when : pools.stdout.find('data') != -1
2019-03-30 20:10:57 -05:00
- 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"
2019-07-30 21:53:57 -05:00
when : not pools.changed and ('worker' in inventory_hostname)