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