From 7530feaff16a82b564c96f72669dd59b7731482b Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Sun, 19 Apr 2020 01:04:02 -0500 Subject: [PATCH] zfs: organize tasks by OS, remove unmaintained tasks --- roles/zfs/tasks/el.yml | 8 +++++ roles/zfs/tasks/main.yml | 64 +++++++-------------------------- roles/zfs/tasks/ubuntu.yml | 7 ++++ roles/zfs/tasks/zfs-release.yml | 19 ++++++++++ 4 files changed, 46 insertions(+), 52 deletions(-) create mode 100644 roles/zfs/tasks/el.yml create mode 100644 roles/zfs/tasks/ubuntu.yml create mode 100644 roles/zfs/tasks/zfs-release.yml diff --git a/roles/zfs/tasks/el.yml b/roles/zfs/tasks/el.yml new file mode 100644 index 000000000..f19204e --- /dev/null +++ b/roles/zfs/tasks/el.yml @@ -0,0 +1,8 @@ +--- + +- name: install zfs packages + package: + name: "{{ item }}" + state: present + with_items: "{{ EL_ZFS_PKGS | difference(ansible_facts.packages) }}" + register: zfs_installed diff --git a/roles/zfs/tasks/main.yml b/roles/zfs/tasks/main.yml index 8e1a779..9f364df 100644 --- a/roles/zfs/tasks/main.yml +++ b/roles/zfs/tasks/main.yml @@ -1,49 +1,16 @@ --- -# TODO: Split tasks into distribution appropriate files -# avoid running/skipping tasks entirely by not including them +- name: include zfs-release tasks (CentOS/RHEL/Fedora) + include_tasks: zfs-release-el.yml + when: ('zfs-release' not in ansible_facts.packages) and (ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux" ]) -# 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: ('zfs-release' not in ansible_facts.packages) and ((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: ('zfs-release' not in ansible_facts.packages) and ((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: ('zfs-release' not in ansible_facts.packages) and (ansible_distribution in ["Fedora"] and not is_atomic) - -- name: install ZFS (Ubuntu) - package: - name: "{{ UBUNTU_ZFS_PKGS | difference(ansible_facts.packages) }}" - state: present +- name: include zfs installation tasks (Ubuntu) + include_tasks: ubuntu.yml when: ansible_distribution in ["Ubuntu"] -- name: install zfs and dkms - package: - name: "{{ EL_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: include zfs installation tasks (CentOS/RHEL/Fedora) + include_tasks: el.yml + when: (ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux", "Fedora" ] and not is_atomic) - name: load zfs module modprobe: @@ -65,15 +32,8 @@ 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) +#- name: create zpool +# command: "zpool create -f -O compression=lz4 data {{ zfs_disk }} -o ashift=13 -O secondarycache=all" +# args: +# creates: /etc/zvol/data/* diff --git a/roles/zfs/tasks/ubuntu.yml b/roles/zfs/tasks/ubuntu.yml new file mode 100644 index 000000000..14d44ad --- /dev/null +++ b/roles/zfs/tasks/ubuntu.yml @@ -0,0 +1,7 @@ +--- + +- name: install ZFS packages + package: + name: "{{ item }}" + state: present + with_items: "{{ UBUNTU_ZFS_PKGS | difference(ansible_facts.packages) }}" diff --git a/roles/zfs/tasks/zfs-release.yml b/roles/zfs/tasks/zfs-release.yml new file mode 100644 index 000000000..02cc47e --- /dev/null +++ b/roles/zfs/tasks/zfs-release.yml @@ -0,0 +1,19 @@ +--- + +- 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_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_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)