2019-02-26 03:49:51 +00:00
|
|
|
---
|
|
|
|
|
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
|
|
|
|
|
2019-02-26 03:49:51 +00:00
|
|
|
- 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 and dkms
|
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
with_items:
|
|
|
|
- kernel-devel
|
|
|
|
- "@Development tools"
|
|
|
|
- dkms
|
|
|
|
- zfs
|
|
|
|
register: zfs_installed
|
|
|
|
when: 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
|
2019-03-31 01:10:57 +00:00
|
|
|
register: zfsload
|
2019-02-26 03:49:51 +00:00
|
|
|
|
2019-03-31 01:10:57 +00:00
|
|
|
# does not adjust to 75% of each host, depends on consistency between hosts - inconsistency leads to disproportionate allocations
|
|
|
|
#- name: set zfs_arc_max to 75% installed memory ({{ zfs_arc_size_bytes }} bytes)
|
2019-02-26 03:49:51 +00:00
|
|
|
# lineinfile:
|
|
|
|
# path: "/etc/modprobe.d/zfs.conf"
|
|
|
|
# regexp: '^options zfs zfs_arc_max='
|
2019-03-31 01:10:57 +00:00
|
|
|
# line: 'options zfs zfs_arc_max="{{ zfs_arc_size_bytes }}"'
|
2019-02-26 03:49:51 +00:00
|
|
|
# create: yes
|
2019-03-31 01:10:57 +00:00
|
|
|
|
|
|
|
- name: import pools
|
|
|
|
command: "zpool import -a"
|
|
|
|
register: pools
|
|
|
|
changed_when: "pools.stderr != 'no pools available to import'"
|
|
|
|
|
|
|
|
- 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: ansible_zfs_pools is not defined
|