Update packages role to better handle cent7 vs 8

This commit is contained in:
Ethan Paul 2019-12-01 14:46:49 -05:00
parent d5fdbbb9aa
commit b98e464f07
4 changed files with 39 additions and 7 deletions

View File

@ -8,6 +8,9 @@
#
# TODO: Host the RPMs locally. The internet may never forget, but it's also never there
# when you need it
#
# NOTE: These tasks only need to be run on Cent8
#
- name: Determine dracut version
shell:

View File

@ -1,13 +1,26 @@
---
- name: Enable Extra Packages for Enterprise Linux
# NOTE: We assume- since this file literally has 'centos' in the name- that the
# ansible_distribution check has already been done at import time
- name: Enable Extra Packages for Enterprise Linux on CentOS 8
become: true
when: ansible_distribution_major_version == "8"
dnf:
state: latest
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
- name: Enable the power tools repository
- name: Enable the power tools repository on CentOS 8
become: true
when: ansible_distribution_major_version == "8"
lineinfile:
path: /etc/yum.repos.d/CentOS-PowerTools.repo
regexp: "enabled=(0|1)"
line: "enabled=1"
- name: Enable Extra Packages for Enterprise Linux on CentOS 7
become: true
when: ansible_distribution_major_version == "7"
dnf:
state: latest
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmz

View File

@ -1,7 +1,14 @@
---
- name: Clean DNF cache
become: true
when: ansible_distribution == "Fedora" or ansible_distribution == "CentOS"
when: ansible_distribution == "Fedora" or (ansible_distribution == "CentOS" and ansible_distribution_major_version == "8")
shell:
cmd: dnf clean all
warn: false
- name: Clean YUM cache
become: true
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
shell:
cmd: yum clean all
warn: false

View File

@ -1,15 +1,24 @@
---
- import_tasks: centos-dracut.yml
when: ansible_distribution == "CentOS"
- import_tasks: centos-8-dracut.yml
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "8"
- name: Upgrade Fedora and CentOS packages
when: ansible_distribution == "CentOS" or ansible_distribution == "Fedora"
- name: Upgrade Fedora and CentOS 8 packages
when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "8") or ansible_distribution == "Fedora"
become: true
dnf:
state: latest
name: "*"
exclude: "{{ ','.join(exclude | default(['kernel*'])) }}"
- name: Upgrade CentOS 7 packages
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
become: true
yum:
state: latest
name: "*"
exclude: "{{ ','.join(exclude | default(['kernel*'])) }}"
# Yeah I'll get here eventually
# - name: Upgrade APT packages
# when: ansible_distribution == "Debian" or ansible_distribution == "Ubuntu"
# become: true