zfs: optimize packages, invoke pkg manager only when required

This commit is contained in:
Josh Lay 2020-04-18 23:10:06 -05:00
parent 3cda795476
commit fad0a40eff
2 changed files with 11 additions and 10 deletions

View file

@ -1,6 +1,10 @@
---
ZFS_PKGS:
EL_ZFS_PKGS:
- kernel-devel
- "@Development tools"
- dkms
- zfs
UBUNTU_ZFS_PKGS:
- zfsutils-linux
- zfs-initramfs

View file

@ -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