diff --git a/roles/zfs/defaults/main.yml b/roles/zfs/defaults/main.yml index 8f97660..1ae6c73 100644 --- a/roles/zfs/defaults/main.yml +++ b/roles/zfs/defaults/main.yml @@ -1,6 +1,10 @@ --- -ZFS_PKGS: +EL_ZFS_PKGS: - kernel-devel - "@Development tools" - dkms - zfs + +UBUNTU_ZFS_PKGS: + - zfsutils-linux + - zfs-initramfs diff --git a/roles/zfs/tasks/main.yml b/roles/zfs/tasks/main.yml index 6d1c3c0..8e1a779 100644 --- a/roles/zfs/tasks/main.yml +++ b/roles/zfs/tasks/main.yml @@ -18,32 +18,29 @@ 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") + 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: (ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux" ]) and (ansible_distribution_major_version == "8") + 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: ansible_distribution in ["Fedora"] and not is_atomic + when: ('zfs-release' not in ansible_facts.packages) and (ansible_distribution in ["Fedora"] and not is_atomic) -- name: install zfs utils (Ubuntu) +- name: install ZFS (Ubuntu) package: - name: "{{ item }}" + name: "{{ UBUNTU_ZFS_PKGS | difference(ansible_facts.packages) }}" 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) }}" + 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